From 7163912397d5e5228a7d3438eff9fb232056ec3a Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 16:47:29 -0700 Subject: [PATCH 01/10] ci: Run coverage with GitHub actions --- .github/workflows/typescript.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/typescript.yml diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml new file mode 100644 index 0000000000..1ec3ba8759 --- /dev/null +++ b/.github/workflows/typescript.yml @@ -0,0 +1,23 @@ +name: TypeScript build CI + +on: + push: { branches: [master] } + pull_request: { branches: [master] } + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn install + - run: yarn test --coverage + - name: Upload coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v3 From feac4b41ee92fedab59179c73b48d89de72cbc6c Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:04:44 -0700 Subject: [PATCH 02/10] ci: Ignore yarn pnp files in coverage --- .codecov.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index 749cb043be..05c989e15b 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,2 +1,5 @@ fixes: - - "datalad_service/::services/datalad/datalad_service/" \ No newline at end of file + - "datalad_service/::services/datalad/datalad_service/" +ignore: + - ".pnp.js" + - ".pnp.loader.mjs" From 872d68f8af8435a8940ba5294cb7d66afe81f6a2 Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:06:14 -0700 Subject: [PATCH 03/10] ci: Disable Node.js coverage in GitLab build. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe9d19d7f1..08d452cc15 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,7 @@ test_nodejs: - ci_env=$(/bin/sh ./scripts/codecov-env) - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker pull $CI_REGISTRY_IMAGE/node:latest || true - - docker run $ci_env -e CI=true $CI_REGISTRY_IMAGE/node:$CI_COMMIT_SHA yarn ci-coverage + - docker run $ci_env -e CI=true $CI_REGISTRY_IMAGE/node:$CI_COMMIT_SHA yarn test build_server: tags: [ saas-linux-medium-amd64 ] From 52593db7cf8ca726a1206355b5d7f10cc6fc0afb Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:18:32 -0700 Subject: [PATCH 04/10] ci: Add Python to GitHub coverage --- .github/workflows/python.yml | 34 ++++++++++++++++++++++++++++++++ .github/workflows/typescript.yml | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000000..b80682cc41 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,34 @@ +name: Python tests and coverage + +on: + push: { branches: [master] } + pull_request: { branches: [master] } + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Use Node.js 18.x + uses: denoland/setup-deno@v1 + with: + node-version: 18.x + - name: Setup Deno stable + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + - name: Install git-annex + run: curl -L http://archive.org/download/git-annex-builds/SHA256E-s53868494--3400215acc1f7f052351d60d17603b36c1338d743b9d8a700eead3dfcd52ad92.tar.gz | tar -C /usr/local/bin --strip-components 1 -xvz + - name: Install pipenv + run: pip install 'pipenv==2023.7.23' + - name: Install dependencies + run: pipenv install --keep-outdated --dev + - name: Run tests and collect coverage + run: pipenv run pytest -n 4 --cov=./datalad_service --cov-report=xml:coverage.xml ./tests + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 \ No newline at end of file diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 1ec3ba8759..20da378e23 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -1,4 +1,4 @@ -name: TypeScript build CI +name: TypeScript tests and coverage on: push: { branches: [master] } From d6b114631aba9bf94b10489c6cb1b5283cceeb20 Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:22:54 -0700 Subject: [PATCH 05/10] ci: Fix pipenv install arguments for Python coverage --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b80682cc41..d1ff41c444 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -27,7 +27,7 @@ jobs: - name: Install pipenv run: pip install 'pipenv==2023.7.23' - name: Install dependencies - run: pipenv install --keep-outdated --dev + run: pipenv install --dev - name: Run tests and collect coverage run: pipenv run pytest -n 4 --cov=./datalad_service --cov-report=xml:coverage.xml ./tests - name: Upload coverage to Codecov From 33350612916f3a48c220b6d5fa7cf56666241660 Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:25:47 -0700 Subject: [PATCH 06/10] ci: Run Python coverage in the right working dir --- .github/workflows/python.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d1ff41c444..a9061b0521 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -4,6 +4,10 @@ on: push: { branches: [master] } pull_request: { branches: [master] } +defaults: + run: + working-directory: ./services/datalad + jobs: run: runs-on: ubuntu-latest From 62cf3da3d230f6c5c1e47b4499f727f8ede92c84 Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:29:20 -0700 Subject: [PATCH 07/10] ci: Fix wrong Node.js action name in Python tests --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a9061b0521..5e285793b4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -19,7 +19,7 @@ jobs: with: python-version: '3.11' - name: Use Node.js 18.x - uses: denoland/setup-deno@v1 + uses: actions/setup-node@v3 with: node-version: 18.x - name: Setup Deno stable From 1b189596800232eed8fa4dddc091e31d792cbd9e Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:32:40 -0700 Subject: [PATCH 08/10] ci: Add git configuration to Python CI environment --- .github/workflows/python.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 5e285793b4..9cd9ddec5f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -32,6 +32,11 @@ jobs: run: pip install 'pipenv==2023.7.23' - name: Install dependencies run: pipenv install --dev + - name: Configure git defaults + run: | + git config --global user.name "Git Worker" + git config --global user.email "ci@openneuro.org" + git config --global receive.denyCurrentBranch updateInstead - name: Run tests and collect coverage run: pipenv run pytest -n 4 --cov=./datalad_service --cov-report=xml:coverage.xml ./tests - name: Upload coverage to Codecov From ff877a87e74ae4913a5cec735135376c617ed9a4 Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 17:49:16 -0700 Subject: [PATCH 09/10] ci: Add new codecov upload token --- .github/workflows/python.yml | 4 +++- .github/workflows/typescript.yml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 9cd9ddec5f..08bb79944a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -40,4 +40,6 @@ jobs: - name: Run tests and collect coverage run: pipenv run pytest -n 4 --cov=./datalad_service --cov-report=xml:coverage.xml ./tests - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 \ No newline at end of file + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 20da378e23..405e8e5e0d 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -21,3 +21,5 @@ jobs: - run: yarn test --coverage - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 6d3ea52ba1164763b8077c8d7bddcf172696e1ad Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Wed, 1 Nov 2023 19:16:02 -0700 Subject: [PATCH 10/10] test: Fix file viewer test to avoid dependency on Node.js error message text --- .../files/viewers/__tests__/file-viewer-json.spec.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/openneuro-app/src/scripts/dataset/files/viewers/__tests__/file-viewer-json.spec.jsx b/packages/openneuro-app/src/scripts/dataset/files/viewers/__tests__/file-viewer-json.spec.jsx index d39dd2800f..0c58fdc48c 100644 --- a/packages/openneuro-app/src/scripts/dataset/files/viewers/__tests__/file-viewer-json.spec.jsx +++ b/packages/openneuro-app/src/scripts/dataset/files/viewers/__tests__/file-viewer-json.spec.jsx @@ -1,5 +1,5 @@ import React from 'react' -import { render } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { FileViewerJsonRaw } from '../file-viewer-json.jsx' describe('File Viewer - JSON', () => { @@ -9,7 +9,7 @@ describe('File Viewer - JSON', () => { expect(asFragment()).toMatchSnapshot() }) it('renders with invalid JSON', () => { - const { asFragment } = render() - expect(asFragment()).toMatchSnapshot() + render() + expect(screen.getByText('JSON failed to parse')).toBeInTheDocument() }) })