|
| 1 | +name: Test SDC Tasks |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + paths: |
| 5 | + - 'individual-shell-tools/**.sh' |
| 6 | + - 'shell-pipelines/**.sh' |
| 7 | + - 'jq/*.sh' |
| 8 | + pull_request_target: |
| 9 | + types: |
| 10 | + - labeled |
| 11 | + - unlabeled |
| 12 | + - opened |
| 13 | + - edited |
| 14 | + - reopened |
| 15 | + |
| 16 | +jobs: |
| 17 | + test_sdc_tasks: |
| 18 | + |
| 19 | + name: Test SDC Tasks |
| 20 | + runs-on: ubuntu-slim |
| 21 | + permissions: |
| 22 | + pull-requests: read |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: checkout pushed PR |
| 26 | + uses: actions/checkout@v5 |
| 27 | + # with: |
| 28 | + # fetch-depth: 2 |
| 29 | + - name: checkout expected output |
| 30 | + uses: actions/checkout@v5 |
| 31 | + with: |
| 32 | + ref: origin/expected-solutions |
| 33 | + path: expect |
| 34 | + - name: Get changed files |
| 35 | + id: changed-files |
| 36 | + uses: tj-actions/changed-files@v47.0.5 |
| 37 | + - name: List all changed files |
| 38 | + env: |
| 39 | + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} |
| 40 | + run: | |
| 41 | + for file in ${ALL_CHANGED_FILES}; do |
| 42 | + echo "$file was changed" |
| 43 | + done |
| 44 | + - name: test individual shell tools |
| 45 | + if: contains(steps.changed-files.outputs.all_changed_files, 'individual-shell-tools/awk/script-01.sh') |
| 46 | + run: ./test-sdc.sh individual-shell-tools |
| 47 | + shell: bash |
| 48 | + - name: test jq |
| 49 | + if: contains(steps.changed-files.outputs.all_changed_files, 'jq/script-01.sh') |
| 50 | + run: ./test-sdc.sh jq |
| 51 | + shell: bash |
| 52 | + - name: test shell-pipelines |
| 53 | + if: contains(steps.changed-files.outputs.all_changed_files, 'shell-pipelines/ls-grep/script-01.sh') |
| 54 | + run: ./test-sdc.sh shell-pipelines |
| 55 | + shell: bash |
| 56 | + - name: read test output |
| 57 | + id: read-test-output |
| 58 | + run: | |
| 59 | + # Read output.txt and write to GITHUB_OUTPUT |
| 60 | + echo 'testoutput<<EOF' >> $GITHUB_OUTPUT |
| 61 | + cat testoutput.txt >> $GITHUB_OUTPUT |
| 62 | + echo EOF |
| 63 | + - name: make output comment |
| 64 | + uses: peter-evans/create-or-update-comment@v5.0.0 |
| 65 | + with: |
| 66 | + issue-number: ${{ github.event.number }} |
| 67 | + body: ${{ steps.read-test-output.outputs.testoutput }} |
| 68 | + |
0 commit comments