Skip to content

Commit

Permalink
Add workflow for detecting a drift in the generated Dagger files
Browse files Browse the repository at this point in the history
  • Loading branch information
zerok committed Jul 3, 2024
1 parent 7e91d5b commit 57fcf60
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Call Dagger Function
id: dagger
uses: dagger/dagger-for-github@11048419d80c283890d0dd68187d44541f63dd89 # v5.11.0
with:
version: "0.11.9"
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/check-dagger-drift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Check for drift in Dagger files"

on:
pull_request:
branches:
- main

jobs:
check-dagger-drift:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Determine Dagger version
id: dagger_version
run: |
sudo apt-get install -y yq
cat .github/workflows/acceptance-tests.yml| yq -r '.jobs.build.steps[] | select(.id == "dagger") | .with.version' > .version
echo "version=$(<.version)" > $GITHUB_OUTPUT
rm -rf .version
- uses: actions/cache@v4
id: cache_daggercli
with:
path: bin
key: daggercli-download-${{ steps.dagger_version.outputs.version }}

- name: Install Dagger CLI
if: steps.cache_daggercli.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=${{ steps.dagger_version.outputs.version }} sh
- name: Check drift
run: |
set -e
make dagger-develop
test -z "$(git status --porcelain)" && "No drift detected" || "Drift detected. Run `make dagger-develop` and commit the changed files"
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ cross: $(GOX)
# Docker container
container: static
docker build -t grafana/tanka .

dagger-develop:
cp dagger/.gitignore{,.bak}
dagger develop
mv dagger/.gitignore{.bak,}

0 comments on commit 57fcf60

Please sign in to comment.