Build boxes #154
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build boxes | |
on: | |
pull_request: | |
push: | |
schedule: | |
- cron: 4 15 * * 6 | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
should_run: | |
name: Should run | |
runs-on: ubuntu-latest | |
outputs: | |
should_run: ${{ steps.check.outputs.should_run }} | |
steps: | |
- name: Check whether workflow should run | |
env: | |
GH_TOKEN: ${{ github.token }} | |
id: check | |
run: | | |
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then | |
echo "This run was triggered by a pull request event" | |
OUTPUT="should_run=true" | |
echo "Setting '$OUTPUT'" | |
echo "$OUTPUT" >> $GITHUB_OUTPUT | |
exit | |
fi | |
BRANCH_NAME="${GITHUB_REF#refs/heads/}" | |
PR_COUNT=$(gh api "repos/${GITHUB_REPOSITORY}/pulls?state=open" \ | |
| jq --arg branch "$BRANCH_NAME" '.[] | select(.head.ref == $branch) | .number' \ | |
| wc -l) | |
if [ $PR_COUNT -gt 0 ]; then | |
echo "There is an associated pull request for branch $BRANCH_NAME" | |
OUTPUT="should_run=false" | |
echo "Setting '$OUTPUT'" | |
echo "$OUTPUT" >> $GITHUB_OUTPUT | |
else | |
echo "There is no associated pull request for branch $BRANCH_NAME" | |
OUTPUT="should_run=true" | |
echo "Setting '$OUTPUT'" | |
echo "$OUTPUT" >> $GITHUB_OUTPUT | |
fi | |
pre-commit: | |
name: Run `pre-commit` | |
needs: should_run | |
if: fromJSON(needs.should_run.outputs.should_run) | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- uses: pre-commit/action@v3.0.1 | |
gbt: | |
name: Get build types | |
needs: pre-commit | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
build-types: ${{ steps.get-build-types.outputs.build-types }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: get-build-types | |
run: | | |
BUILDS=$(jq -cR 'split(" ")' builds) | |
OUTPUT="build-types=$BUILDS" | |
echo "Setting '$OUTPUT'" | |
echo "$OUTPUT" >> $GITHUB_OUTPUT | |
gov: | |
name: Get OS versions | |
needs: pre-commit | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
os-versions: ${{ steps.get-os-versions.outputs.os-versions }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: get-os-versions | |
run: | | |
VERSIONS=$(jq -cR 'split(" ")' os_vers) | |
OUTPUT="os-versions=$VERSIONS" | |
echo "Setting '$OUTPUT'" | |
echo "$OUTPUT" >> $GITHUB_OUTPUT | |
build-boxes: | |
needs: | |
- gbt | |
- gov | |
uses: ./.github/workflows/libbuild.yml | |
secrets: inherit | |
strategy: | |
fail-fast: false | |
matrix: | |
build-os-version: ${{ fromJSON(needs.gov.outputs.os-versions) }} | |
build-runner: [buildjet-2vcpu-ubuntu-2204, virtualbox] | |
build-type: ${{ fromJSON(needs.gbt.outputs.build-types) }} | |
exclude: | |
- build-type: qemu-x64 | |
build-runner: virtualbox | |
- build-type: vbox-x64 | |
build-runner: buildjet-2vcpu-ubuntu-2204 | |
with: | |
build-os-version: ${{ matrix.build-os-version }} | |
build-runner: ${{ matrix.build-runner }} | |
build-type: ${{ matrix.build-type }} | |
timeout-minutes: 20 | |
results: | |
name: Collect results | |
needs: | |
- build-boxes | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "Builds succeeded!" | |
- name: Update Healthchecks.io | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
run: curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/${HC_UUID} | |
env: | |
HC_UUID: ${{ secrets.HC_UUID }} |