Skip to content

Test All Samples

Test All Samples #990

name: Test All Samples
on:
merge_group:
schedule:
- cron: '30 1 * * *'
workflow_dispatch: {}
pull_request:
branches:
- main
paths:
- 'scripts/.util/tools.json'
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.paths.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Discover changed paths
id: paths
run: |
set -eo pipefail
all_java_smoke_test_paths=$( find ./java -iname "smoke_test" | jq --raw-input | jq --slurp --compact-output )
all_other_smoke_test_paths='["ca-certificates","dotnet-core","git","go","nodejs","php","procfile","python","ruby","web-servers"]'
all_paths=$( echo -e "$all_java_smoke_test_paths\n$all_other_smoke_test_paths" | jq -s 'add' -c )
echo "These are the Java projects we'll run smoke tests against: $all_java_smoke_test_paths" >> $GITHUB_STEP_SUMMARY
echo "These are the other folders we'll run smoke tests against: : $all_other_smoke_test_paths" >> $GITHUB_STEP_SUMMARY
echo "These are all the smoke test locations: $all_paths" >> $GITHUB_STEP_SUMMARY
echo "matrix={\"suite\":$all_paths}" >> $GITHUB_OUTPUT
echo "This is how the matrix will look like: $(cat $GITHUB_OUTPUT)"
smoke:
needs: prepare
name: Smoke Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout
uses: actions/checkout@v4
- name: Test ${{ matrix.suite }}
run: |
./scripts/smoke.sh --builder paketobuildpacks/builder-jammy-full:latest --suite ${{ matrix.suite }}
- name: File Issue
if: ${{ failure() && github.event_name != 'pull_request' }}
run: |
echo "${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}" | gh auth login --with-token
failure_issue=$(gh issue list --json number --label "test-failure" --jq .[0].number)
if [ -z $failure_issue ]; \
then gh issue create \
--title "Failure: 'Test All Samples' workflow" \
--label "test-failure" \
--body "[Test ${{ matrix.suite }} workflow](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) failed. Please take a look to ensure samples are working. (cc @paketo-buildpacks/content-maintainers)" \
-R ${{github.repository}}; \
else gh issue comment $failure_issue --body "Another failure occurred: [Test ${{ matrix.suite }} workflow](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) failed."; \
fi
echo $failure_issue