From c66139ef7fd03f1830c7cb8f4d51b07ce0cb2894 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Sat, 27 Jul 2024 00:23:34 -0400 Subject: [PATCH] GHA testing --- .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++++++ README.md | 6 ------ docker-compose.yml | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..86eddc3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test + +on: + push: + branches: [ master ] + paths: + - '.github/workflows/test.yml' + - '**.py' + pull_request: + +jobs: + test: + name: Tests + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Spin up ChRIS + uses: FNNDSC/miniChRIS-docker@master + with: + # for testing, we need to create plugin instances, but we don't need the plugins to actually run. + services: chris oxidicom graphql-engine + - name: Build + run: docker compose build test + - name: Test + id: test + continue-on-error: true # we want to upload coverage, even on failure + run: docker compose run -T --use-aliases test + - name: Copy coverage.xml from container + run: docker cp "$(docker compose ps -a test -q | tail -n 1):/app/coverage.xml" coverage.xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: ./coverage.xml + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 7257193..98f10a9 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,6 @@ so we need to run them with Docker Compose: docker compose run test ``` -Coverage data can be obtained from the stopped test container: - -```shell -docker cp "$(docker compose ps -a test -q | tail -n 1):/app/coverage.xml" coverage.xml -``` - ### Deployment See https://github.com/FNNDSC/charts diff --git a/docker-compose.yml b/docker-compose.yml index e27f979..b81a50e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: context: . args: REQUIREMENTS_FILE: requirements-dev.lock - command: pytest --run-e2e --cov=serie --cov-report=xml + command: pytest --color=yes --run-e2e --cov=serie --cov-report=xml working_dir: /app volumes: # /app is a volume and the source code files are binded as subdirectories