Skip to content

Commit

Permalink
ci: conditional build
Browse files Browse the repository at this point in the history
  • Loading branch information
farioas committed Jan 9, 2025
1 parent 05b4add commit 45ba6d8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
with:
name: codecov-general
Expand All @@ -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/[email protected]
with:
name: codecov-${{ matrix.backend_dir_name }}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 45ba6d8

Please sign in to comment.