From 45ba6d8061b50719408f9cac7ff622f9286db310 Mon Sep 17 00:00:00 2001 From: Sergey Zhuk Date: Thu, 9 Jan 2025 14:19:51 +0000 Subject: [PATCH] ci: conditional build --- .github/workflows/tests.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e24583c5..7e53df1d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -91,7 +91,7 @@ jobs: env: DOCKER_BUILDKIT: 1 TEST_ENV: "true" - run: docker compose -f label_studio_ml/examples/${{ matrix.backend_dir_name }}/docker-compose.yml up -d --build + run: docker compose -f label_studio_ml/examples/${{ matrix.backend_dir_name }}/docker-compose.yml up ${{ matrix.skip_pytests != 'true' && '' || '-d' }} --build - name: Wait for stack timeout-minutes: 20 @@ -101,29 +101,32 @@ jobs: done - name: Run general functional tests + if: ${{ matrix.skip_pytests != 'true' }} env: ML_BACKEND: ${{ matrix.backend_dir_name }} run: | pytest tests/ -vvv --ignore-glob='**/logs/*' --ignore-glob='**/data/*' --cov=. --cov-report=xml:tests/${{ matrix.backend_dir_name }}_coverage.xml - name: Run per-ml-backend tests + if: ${{ matrix.skip_pytests != 'true' }} env: ML_BACKEND: ${{ matrix.backend_dir_name }} run: | docker compose -f label_studio_ml/examples/${{ matrix.backend_dir_name }}/docker-compose.yml exec -T ${{ matrix.backend_dir_name }} pytest -vvv --cov --cov-report=xml:/tmp/coverage.xml - name: Copy per-ml-backend coverage.xml from the container + if: ${{ matrix.skip_pytests != 'true' }} run: | docker compose -f label_studio_ml/examples/${{ matrix.backend_dir_name }}/docker-compose.yml cp ${{ matrix.backend_dir_name }}:/tmp/coverage.xml label_studio_ml/examples/${{ matrix.backend_dir_name }}/coverage.xml - name: Pull the logs - if: always() + if: always() && matrix.skip_pytests != 'true' env: DOCKER_BUILDKIT: 1 run: docker compose -f label_studio_ml/examples/${{ matrix.backend_dir_name }}/docker-compose.yml logs - name: "Upload general coverage to Codecov" - if: ${{ matrix.backend_dir_name == 'the_simplest_backend' }} + if: ${{ matrix.backend_dir_name == 'the_simplest_backend' && matrix.skip_pytests != 'true' }} uses: codecov/codecov-action@v5.1.2 with: name: codecov-general @@ -132,6 +135,7 @@ jobs: fail_ci_if_error: false - name: "Upload ml-backend ${{ matrix.backend_dir_name }} coverage to Codecov" + if: ${{ matrix.backend_dir_name == 'the_simplest_backend' && matrix.skip_pytests != 'true' }} uses: codecov/codecov-action@v5.1.2 with: name: codecov-${{ matrix.backend_dir_name }} @@ -201,19 +205,21 @@ jobs: for (const backend of backends) { const config = docker_build_config.find(e => e.backend_dir_name === backend) let runs_on = "ubuntu-latest"; + let skip_pytests = "false"; if (config) { console.log(`Config for ${backend}:`); console.log(config); if ((config.bypass ?? []).includes("pytests")) { console.log(`Skipping pytests for ${backend}`); - continue; + skip_pytests = "true"; } runs_on = config.runs_on ?? "ubuntu-latest"; } else { console.log(`Could not find config for ${backend}`); } - matrixInclude.push({"backend_dir_name": backend, "runs_on": runs_on}); + matrixInclude.push({"backend_dir_name": backend, "runs_on": runs_on, "skip_pytests": skip_pytests}); } + console.log(`Matrix calculation result:`); console.log(matrixInclude); core.setOutput("matrix-include", matrixInclude);