Skip to content

Commit

Permalink
Hack more on per commit idea
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-noland committed Nov 30, 2024
1 parent e12cb00 commit f20907d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
| jq --null-input --raw-output --compact-output '[inputs] | "commits=" + (. | tostring)' \
| tee -a "${GITHUB_OUTPUT}"
build:
build-and-test:
needs: [ check_changes, commits ]
if: "${{ needs.check_changes.outputs.devfiles == 'true' }}"
strategy:
Expand Down Expand Up @@ -184,3 +184,17 @@ jobs:
timeout-minutes: 60
with:
limit-access-to-actor: true


summary:
name: "Dev Test and Build"
if: ${{ always() }}
runs-on: "ubuntu-latest"
needs:
- build-and-test
steps:
- name: "Flag any build matrix failures"
if: ${{ needs.build-and-test.result != 'success' }}
run: |
>&2 echo "A critical step failed!"
exit 1
59 changes: 40 additions & 19 deletions .github/workflows/sterile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
name: "sterile.yml"

on:
pull_request: {}
pull_request: { }
push:
branches:
- "main"
merge_group:
types: ["checks_requested"]
types: [ "checks_requested" ]
workflow_dispatch:
inputs:
debug_enabled:
Expand All @@ -24,30 +24,34 @@ concurrency:
cancel-in-progress: true

jobs:
check_changes:
name: "Deduce required tests from code changes"
commits:
name: "Track commits"
runs-on: "ubuntu-latest"
outputs:
devfiles: "${{ steps.changes.outputs.devfiles }}"
commits: "${{ steps.commits.outputs.commits }}"
steps:
- name: "install jq"
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install --yes --no-install-recommends jq
- name: "Checkout"
if: "${{ !github.event.pull_request }}"
uses: "actions/checkout@v4"
with:
persist-credentials: "false"
fetch-depth: "0"
- name: "Check code changes"
uses: "dorny/paths-filter@v3"
id: "changes"
with:
filters: |
devfiles:
- '!(README.md|LICENSE|design-docs/**|.gitignore|.github/**)'
- '.github/workflows/sterile.yml'
- name: "commits"
id: "commits"
run: |
set -euxo pipefail
git rev-list --pretty=oneline ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
| sed -e 's/ /", "msg": "/' -e 's/^/{"ref": "/' -e 's/$/"}/' \
| jq --null-input --raw-output --compact-output '[inputs] | "commits=" + (. | tostring)' \
| tee -a "${GITHUB_OUTPUT}"
test:
needs: [ check_changes ]
if: "${{ needs.check_changes.outputs.devfiles == 'true' }}"
needs: [ commits ]
permissions:
contents: "read"
packages: "read"
Expand All @@ -56,9 +60,10 @@ jobs:
strategy:
fail-fast: false
matrix:
commit: ${{ fromJSON(needs.commits.outputs.commits) }}
rust:
- "stable"
name: "Sterile test run (Rust ${{ matrix.rust }})"
name: "${{matrix.commit.msg}} [sterile/test/rust/${{ matrix.rust }}/${{matrix.commit.ref}}]"
steps:
- name: "login to ghcr.io"
uses: "docker/login-action@v3"
Expand All @@ -80,6 +85,9 @@ jobs:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ matrix.commit.ref }}
fetch-depth: '1'

- name: "dev/gnu sterile test"
if: ${{ always() }}
Expand Down Expand Up @@ -155,7 +163,7 @@ jobs:
- uses: "actions/upload-artifact@v4"
if: ${{ always() }}
with:
name: 'rust-${{matrix.rust}}-test-results'
name: 'rust-${{matrix.rust}}-test-results-${{matrix.commit.ref}}'
path: "target/nextest"

- name: "Setup tmate session for debug"
Expand All @@ -166,8 +174,7 @@ jobs:
limit-access-to-actor: true

push:
needs: [ check_changes ]
if: "${{ needs.check_changes.outputs.devfiles == 'true' }}"
needs: [ commits ]
permissions:
contents: "read"
packages: "write"
Expand Down Expand Up @@ -227,3 +234,17 @@ jobs:
timeout-minutes: 60
with:
limit-access-to-actor: true

summary:
name: "sterile"
if: ${{ always() }}
runs-on: "ubuntu-latest"
needs:
- push
- test
steps:
- name: "Flag any build matrix failures"
if: ${{ needs.run.result != 'success' }}
run: |
>&2 echo "A critical step failed!"
exit 1

0 comments on commit f20907d

Please sign in to comment.