Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Run coverage with GitHub actions #2933

Merged
merged 10 commits into from
Nov 2, 2023
5 changes: 4 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
fixes:
- "datalad_service/::services/datalad/datalad_service/"
- "datalad_service/::services/datalad/datalad_service/"
ignore:
- ".pnp.js"
- ".pnp.loader.mjs"
45 changes: 45 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Python tests and coverage

on:
push: { branches: [master] }
pull_request: { branches: [master] }

defaults:
run:
working-directory: ./services/datalad

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: actions/setup-node@v3
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 --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
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: TypeScript tests and coverage

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
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand All @@ -9,7 +9,7 @@ describe('File Viewer - JSON', () => {
expect(asFragment()).toMatchSnapshot()
})
it('renders with invalid JSON', () => {
const { asFragment } = render(<FileViewerJsonRaw jsonRaw="1234;" />)
expect(asFragment()).toMatchSnapshot()
render(<FileViewerJsonRaw jsonRaw="1234;" />)
expect(screen.getByText('JSON failed to parse')).toBeInTheDocument()
})
})