feat: Improve build pipeline (#78)
This pull request enhances the `.github/workflows/update-flake.yaml` file by adding new features and improving the build and validation process. The key changes include allowing manual triggering, adding a matrix strategy to run jobs on multiple operating systems, and implementing steps to handle build and check failures by creating issues automatically. Enhancements to build and validation process: * [`.github/workflows/update-flake.yaml`](diffhunk://#diff-4a139fc25db101424a99bb7668e55ce5a6a6f32aa9a3ed5838b638a3d14e4a4cR1-R68): Added `workflow_dispatch` to allow manual triggering of the workflow. * [`.github/workflows/update-flake.yaml`](diffhunk://#diff-4a139fc25db101424a99bb7668e55ce5a6a6f32aa9a3ed5838b638a3d14e4a4cR1-R68): Introduced a matrix strategy to run jobs on both `ubuntu-latest` and `macos-latest`, and included `fail-fast: false` to continue with other jobs even if one fails. * [`.github/workflows/update-flake.yaml`](diffhunk://#diff-4a139fc25db101424a99bb7668e55ce5a6a6f32aa9a3ed5838b638a3d14e4a4cR1-R68): Added a step to build and test the configuration, capturing the output and setting the build status in the environment variables. * [`.github/workflows/update-flake.yaml`](diffhunk://#diff-4a139fc25db101424a99bb7668e55ce5a6a6f32aa9a3ed5838b638a3d14e4a4cR1-R68): Implemented a step to create an issue on build failure, using `actions/github-script@v7` to post the build output in the issue description. * [`.github/workflows/update-flake.yaml`](diffhunk://#diff-4a139fc25db101424a99bb7668e55ce5a6a6f32aa9a3ed5838b638a3d14e4a4cR77-R120): Added steps to run checks and create an issue on check failure, similar to the build failure handling.
This commit is contained in:
parent
7090b197a7
commit
e7b86939a8
1 changed files with 100 additions and 3 deletions
103
.github/workflows/update-flake.yaml
vendored
103
.github/workflows/update-flake.yaml
vendored
|
|
@ -1,18 +1,71 @@
|
||||||
|
name: Update Flake and Validate Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "30 00 * * 1"
|
- cron: "30 00 * * 1"
|
||||||
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lockfile:
|
build-and-update:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
fail-fast: false # Continue with other jobs even if one fails
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Repository Checkout
|
- name: Repository Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Instal Nix
|
- name: Install Nix
|
||||||
uses: DeterminateSystems/nix-installer-action@v16
|
uses: DeterminateSystems/nix-installer-action@v16
|
||||||
|
|
||||||
|
- name: Build and Test Configuration
|
||||||
|
id: build
|
||||||
|
continue-on-error: true # Continue to next steps even if build fails
|
||||||
|
run: |
|
||||||
|
# Run the build and capture output
|
||||||
|
OUTPUT=$(nix build .# 2>&1)
|
||||||
|
echo "build_output<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$OUTPUT" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Check if build succeeded
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "build_status=success" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "build_status=failure" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create Issue on Build Failure
|
||||||
|
if: env.build_status == 'failure'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const os = '${{ matrix.os }}';
|
||||||
|
const buildOutput = process.env.build_output;
|
||||||
|
|
||||||
|
await github.rest.issues.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.name,
|
||||||
|
title: `🔨 Build Failed on ${os}`,
|
||||||
|
body: `Build failed during automated validation on ${os}.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Build Output</summary>
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
${buildOutput}
|
||||||
|
\`\`\`
|
||||||
|
</details>
|
||||||
|
|
||||||
|
Please review the build output and fix any issues.`,
|
||||||
|
labels: ['build-failure', 'bug']
|
||||||
|
});
|
||||||
|
|
||||||
- name: Update flake.lock
|
- name: Update flake.lock
|
||||||
|
if: matrix.os == 'ubuntu-latest' && env.build_status == 'success'
|
||||||
uses: DeterminateSystems/update-flake-lock@v24
|
uses: DeterminateSystems/update-flake-lock@v24
|
||||||
with:
|
with:
|
||||||
nix-options: --debug --log-format raw
|
nix-options: --debug --log-format raw
|
||||||
|
|
@ -21,3 +74,47 @@ jobs:
|
||||||
pr-labels: |
|
pr-labels: |
|
||||||
dependencies
|
dependencies
|
||||||
automated
|
automated
|
||||||
|
|
||||||
|
- name: Run Checks
|
||||||
|
id: checks
|
||||||
|
if: env.build_status == 'success'
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
# Run the checks and capture output
|
||||||
|
OUTPUT=$(nix flake check 2>&1)
|
||||||
|
echo "check_output<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$OUTPUT" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Check if checks succeeded
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "check_status=success" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "check_status=failure" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create Issue on Check Failure
|
||||||
|
if: env.check_status == 'failure'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const os = '${{ matrix.os }}';
|
||||||
|
const checkOutput = process.env.check_output;
|
||||||
|
|
||||||
|
await github.rest.issues.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.name,
|
||||||
|
title: `⚠️ Checks Failed on ${os}`,
|
||||||
|
body: `Checks failed during automated validation on ${os}.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Check Output</summary>
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
${checkOutput}
|
||||||
|
\`\`\`
|
||||||
|
</details>
|
||||||
|
|
||||||
|
Please review the check output and fix any issues.`,
|
||||||
|
labels: ['check-failure', 'bug']
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue