Skip to content
Draft
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions .github/workflows/bless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Bless Test Output

on:
pull_request_target:
types: [labeled]

permissions:
contents: write
pull-requests: write

jobs:
bless:
name: Bless test output
runs-on: ubuntu-latest
if: contains(github.event.label.name, 'bless')

steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Rust
run: rustup update stable && rustup default stable

- name: Install just
uses: taiki-e/install-action@cc60de1d6831d7e9c4342f618ce7a5d6a9f223a4 # v2.61.6
with:
tool: just

- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0

- name: Install frontend dependencies
run: npm install
working-directory: martin/martin-ui

- name: Setup PostGIS
uses: nyurik/action-setup-postgis@228cfe4dd41aad01801a0bdc767040e5024fff1d # v2
id: postgres
- name: Setup NGINX
uses: nyurik/action-setup-nginx@612ee9cb839ad727832cda16359452e7e14dd521 # v1.1
id: nginx

- name: Copy static test files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}

- name: Initialize database
run: tests/fixtures/initdb.sh
env:
DATABASE_URL: ${{ postgres.outputs.connection-uri }}

- name: Install system dependencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a near-perfect dup of all the setup steps, could we just move all the common setup logic to a private action -- see exampls in https://github.com/maplibre/maplibre-rs/tree/main/.github/actions/setup

run: sudo apt-get install -y gdal-bin sqlite3-tools

- name: Debug environment
run: |
echo "User: $USER"
echo "GitHub Actor: ${{ github.actor }}"
echo "Database URL: ${{ postgres.outputs.connection-uri }}

- name: Run just bless
run: |
echo "Running just bless..."
just bless
env:
DATABASE_URL: ${{ postgres.outputs.connection-uri }}

- name: Commit blessed output
id: commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action (bless)"

echo "Checking for changes..."
git status
git add -A

if ! git diff --cached --quiet; then
echo "Changes detected, committing..."
git commit -m "Bless test output [skip ci]"
echo "Pushing changes..."
git push origin ${{ github.event.pull_request.head.ref }}
echo "✅ Test output blessed and committed"
echo "changes_made=true" >> $GITHUB_OUTPUT
else
echo "ℹ️ No changes to commit"
echo "changes_made=false" >> $GITHUB_OUTPUT
fi

- name: Remove bless label
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'bless'
});
console.log('Label removed successfully');
} catch (error) {
console.log('Could not remove label:', error.message);
}

- name: Add comment
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
const changesMade = '${{ steps.commit.outputs.changes_made }}' === 'true';
const jobStatus = '${{ job.status }}';

let body;
if (jobStatus === 'failure') {
body = '❌ Blessing failed. Please check the workflow logs for details.';
} else if (changesMade) {
body = '🎉 Test output has been blessed! The expected output files have been updated to match the current test results.';
} else {
body = 'ℹ️ No changes were needed. The test output already matches the expected results.';
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
Loading