Skip to content

Commit 7358b49

Browse files
authoredMar 1, 2024··
fix(build): early exit strategy for modules (#437)
# changes Fix build where cancelling the builds were reported as failures (`gh run cancel` isn't just cancel but fail too). Now we produce a dynamic matrix instead and safely skip the test AND report that we've skipped. :pray:
1 parent 2db8e6d commit 7358b49

File tree

2 files changed

+33
-42
lines changed

2 files changed

+33
-42
lines changed
 

‎.github/workflows/ci-community.yml

+30-42
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,51 @@ name: modules
44

55
on:
66
push:
7-
branches: [main]
7+
branches: [ main ]
88
paths:
99
- "modules/**"
1010
pull_request:
11-
branches: [main]
11+
branches: [ main ]
1212
paths:
1313
- "modules/**"
1414

15-
permissions:
16-
actions: write # needed for self-cancellation
17-
1815
jobs:
19-
test:
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
python-version: ["3.11"]
24-
module:
25-
- arangodb
26-
- azurite
27-
- clickhouse
28-
- elasticsearch
29-
- google
30-
- kafka
31-
- keycloak
32-
- localstack
33-
- minio
34-
- mongodb
35-
- mssql
36-
- mysql
37-
- neo4j
38-
- nginx
39-
- opensearch
40-
- oracle
41-
- postgres
42-
- rabbitmq
43-
- redis
44-
- selenium
45-
- k3s
16+
track-modules:
4617
runs-on: ubuntu-latest
4718
steps:
4819
- name: Checkout contents
4920
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # recommended by tj-actions/changed-files
5023
- name: Get changed files
51-
id: changes-for-module
24+
id: changed-files
5225
uses: tj-actions/changed-files@v42
5326
with:
54-
files: |
55-
modules/${{ matrix.module }}/**
56-
- name: Exit early, nothing to do
57-
if: ${{ steps.changes-for-module.outputs.any_changed == 'false' }}
27+
path: "./modules"
28+
diff_relative: true
29+
dir_names: true
30+
dir_names_exclude_current_dir: true
31+
json: true
32+
- name: Compute modules from files
33+
id: compute-changes
5834
run: |
59-
# cancel and wait for run to end
60-
gh run cancel ${{ github.run_id }}
61-
gh run watch ${{ github.run_id }}
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
modules=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | jq '.[] | split("/") | first' | jq -s -c '. | unique')
36+
echo "computed_modules=$modules"
37+
echo "computed_modules=$modules" >> $GITHUB_OUTPUT
38+
outputs:
39+
changed_modules: ${{ steps.compute-changes.outputs.computed_modules }}
40+
test:
41+
needs: [track-modules]
42+
if: ${{ needs.track-modules.outputs.changed_modules != '[]' }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
python-version: [ "3.11" ]
47+
module: ${{ fromJSON(needs.track-modules.outputs.changed_modules) }}
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout contents
51+
uses: actions/checkout@v4
6452
- name: Set up Python
6553
uses: ./.github/actions/setup-env
6654
with:

‎modules/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Modules
2+
3+
The modules directory contains all the community-supported containers that see common use cases and merit their own easy-access container.

0 commit comments

Comments
 (0)
Please sign in to comment.