|
6 | 6 | types: [synchronize, opened, reopened, ready_for_review] |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - set-matrix-job: |
10 | | - name: Set jobs by changed Dockerfile |
11 | | - runs-on: ubuntu-latest |
| 9 | + prepare-matrix-jobs: |
| 10 | + name: Prepare Build and Test Jobs |
| 11 | + runs-on: "ubuntu-latest" |
12 | 12 | outputs: |
13 | | - sorters: ${{ steps.set-matrix.outputs.sorters }} |
| 13 | + has_changed_files: ${{ steps.changed-files.outputs.any_changed }} |
| 14 | + sorters: ${{ steps.get-changed-sorters.outputs.sorters }} |
14 | 15 | steps: |
15 | | - - name: Checkount |
| 16 | + - name: Checkout |
16 | 17 | uses: actions/checkout@v3 |
17 | 18 |
|
18 | 19 | - name: Get changed files |
19 | 20 | id: changed-files |
20 | 21 | uses: tj-actions/changed-files@v23 |
| 22 | + with: |
| 23 | + files: | |
| 24 | + */Dockerfile |
21 | 25 |
|
22 | | - - name: Set jobs' matrix |
23 | | - id: set-matrix |
| 26 | + - name: Prepare jobs matrix |
| 27 | + id: get-changed-sorters |
24 | 28 | run: | |
| 29 | + # sorters variable will be a JSON-like array |
25 | 30 | sorters="[" |
26 | | - for file in /Dockerfilesabc/Dockerfiles def/Dockerfiles huea; do |
27 | | - if [[ "$file" == *"Dockerfile"* ]]; then |
28 | | - # Removing /Dockerfile from string |
29 | | - parsed=${file%*/Dockerfile*} |
30 | | -
|
31 | | - # Appending to sorters Array |
32 | | - sorters+="\"${parsed}\", " |
33 | | - fi |
| 31 | +
|
| 32 | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do |
| 33 | + # Removing /Dockerfile from string |
| 34 | + parsed=${file%*/Dockerfile*} |
| 35 | +
|
| 36 | + # Appending to final string |
| 37 | + sorters+="\"${parsed}\", " |
34 | 38 | done |
35 | 39 | sorters=${sorters%*, *} |
36 | 40 | sorters+="]" |
37 | | - echo $sorters |
38 | 41 |
|
| 42 | + echo ${sorters} |
39 | 43 | echo "::set-output name=sorters::${sorters}" |
40 | | - test: |
41 | | - needs: set-matrix-job |
42 | | - runs-on: "ubuntu-latest" |
| 44 | +
|
| 45 | + build-and-test-image: |
| 46 | + name: build (${{ matrix.sorter }}) |
| 47 | + if: needs.prepare-matrix-jobs.outputs.has_changed_files == 'true' |
| 48 | + needs: prepare-matrix-jobs |
| 49 | + runs-on: ${{ matrix.os }} |
43 | 50 | strategy: |
| 51 | + fail-fast: false |
44 | 52 | matrix: |
45 | | - sorter: ${{ fromJSON(needs.set-matrix-job.outputs.matrix) }} |
| 53 | + # "macos-latest", "windows-latest" |
| 54 | + os: ["ubuntu-latest", ] |
| 55 | + sorter: ${{ fromJSON(needs.prepare-matrix-jobs.outputs.sorters) }} |
46 | 56 | steps: |
47 | | - - run: echo ${{ matrix.sorter }} |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v3 |
| 59 | + with: |
| 60 | + python-version: 3.8 |
| 61 | + |
| 62 | + - name: Build ${{ matrix.sorter }} Docker image |
| 63 | + run: | |
| 64 | + cd ${{ matrix.sorter }} |
| 65 | + bash build.sh |
| 66 | + cd .. |
| 67 | +
|
| 68 | + - uses: eWaterCycle/setup-singularity@v7 |
| 69 | + with: |
| 70 | + singularity-version: 3.8.3 |
| 71 | + |
| 72 | + - name: Install dependencies & Test ${{ matrix.sorter }} image |
| 73 | + run: | |
| 74 | + if [[ ${{ matrix.sorter }} == 'tridesclous' ]] |
| 75 | + pip install tridesclous |
| 76 | + fi |
| 77 | + pip install -r requirements_test.txt |
| 78 | + pytest -sv tests/test_singularity_containers.py::test_${{ matrix.sorter }} |
0 commit comments