Skip to content

Commit 52081e7

Browse files
committed
ci: add GitHub workflows and Dependabot configuration
- Add build workflow for cross-platform testing - Add automated flake lock updates workflow - Configure Dependabot for GitHub Actions and Cargo updates Signed-off-by: Qiming Chu <cchuqiming@gmail.com>
1 parent 6e25a77 commit 52081e7

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "cargo"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Build gperf2flamegraph"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
build:
11+
name: Build on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: cachix/install-nix-action@v31
19+
- name: Flake check
20+
run: nix flake check --all-systems
21+
- name: Build gperf2flamegraph
22+
run: nix build '.#gperf2flamegraph'
23+
- name: Upload gperf2flamegraph
24+
uses: actions/upload-artifact@v4.6.1
25+
with:
26+
name: gperf2flamegraph-${{ matrix.os }}
27+
path: result/bin/gperf2flamegraph

.github/workflows/update.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Update flake lock
2+
on:
3+
schedule:
4+
# Trigger every Monday and Thursday at 8:00 UTC
5+
- cron: '0 8 * * 1'
6+
workflow_dispatch: # Allow manual triggering
7+
jobs:
8+
update-flake-lock:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: DeterminateSystems/nix-installer-action@main
16+
- uses: DeterminateSystems/magic-nix-cache-action@main
17+
- name: Update flake lock
18+
run: |
19+
nix flake update
20+
- name: Build gperf2flamegraph
21+
run: |
22+
nix build '.#gperf2flamegraph'
23+
- name: Create Pull Request
24+
run: |
25+
echo "Creating a new pull request..."
26+
UPDATE_DATE=$(date +%Y-%m-%d)
27+
BRANCH_NAME="update-flake-lock"
28+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
29+
git config --global user.name "GitHub Actions[bot]"
30+
git fetch origin
31+
# Create a new branch
32+
echo "Creating a new branch..."
33+
git checkout -b $BRANCH_NAME
34+
git add flake.lock
35+
if ! git diff --quiet --cached --exit-code; then
36+
updatedFiles=$(git diff --cached --name-only)
37+
echo "Have changes: $updatedFiles"
38+
git commit -m "chore: update flake lock to $UPDATE_DATE"
39+
# Push the changes
40+
echo "Pushing changes..."
41+
git push origin "$BRANCH_NAME" --force-with-lease
42+
# Create a new PR
43+
echo "Creating a new PR..."
44+
gh pr create \
45+
--reviewer Emin017 \
46+
--title "chore: update flake lock $UPDATE_DATE" \
47+
--body "Auto-generated PR to merge '$BRANCH_NAME' into 'main', changes:$updatedFiles" \
48+
--base main \
49+
--head "$BRANCH_NAME" \
50+
--repo "${{ github.repository }}"
51+
echo "PR created!"
52+
fi
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)