Skip to content

Commit 709dd82

Browse files
authored
CI: more macOS versions; automatically build fpm bottles
2 parents bfa1ed5 + 7b5dd13 commit 709dd82

File tree

2 files changed

+102
-7
lines changed

2 files changed

+102
-7
lines changed

.github/workflows/fpm-version-update.yml

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
jobs:
99
update-fpm:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
1114

1215
steps:
1316
- name: Checkout repository
@@ -48,18 +51,103 @@ jobs:
4851
echo "SHA256=${SHA256}" >> "$GITHUB_ENV"
4952
echo "New SHA256: ${SHA256}"
5053
54+
- name: Create branch for update
55+
if: env.UPDATE_NEEDED == 'true'
56+
run: |
57+
BRANCH_NAME="auto-update-fpm-${LATEST_VERSION}"
58+
git checkout -b "${BRANCH_NAME}"
59+
echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_ENV"
60+
5161
- name: Update formula
5262
if: env.UPDATE_NEEDED == 'true'
5363
run: |
5464
sed -i "s|url \".*\"|url \"https://github.com/fortran-lang/fpm/releases/download/${LATEST_VERSION_V}/fpm-${LATEST_VERSION}.zip\"|" Formula/fpm.rb
5565
sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" Formula/fpm.rb
5666
57-
- name: Commit and push changes
67+
- name: Commit changes
5868
if: env.UPDATE_NEEDED == 'true'
5969
run: |
6070
git config --global user.name "GitHub Actions"
6171
git config --global user.email "[email protected]"
6272
git add Formula/fpm.rb
6373
git commit -m "Update fpm to ${LATEST_VERSION}"
64-
git push
6574
75+
- name: Push changes to branch
76+
if: env.UPDATE_NEEDED == 'true'
77+
run: |
78+
git push origin "${BRANCH_NAME}"
79+
80+
- name: Create Pull Request
81+
if: env.UPDATE_NEEDED == 'true'
82+
id: create-pr
83+
uses: peter-evans/create-pull-request@v5
84+
with:
85+
token: ${{ secrets.GITHUB_TOKEN }}
86+
commit-message: "Update fpm to ${{ env.LATEST_VERSION }}"
87+
title: "Update fpm to ${{ env.LATEST_VERSION }}"
88+
body: |
89+
This PR automatically updates the fpm formula to version ${{ env.LATEST_VERSION }}.
90+
91+
**Changes:**
92+
- Updated URL to ${{ env.LATEST_VERSION_V }} release
93+
- Updated SHA256 to match the new release
94+
95+
This PR was created automatically by GitHub Actions.
96+
branch: ${{ env.BRANCH_NAME }}
97+
base: main
98+
labels: |
99+
automated-pr
100+
version-bump
101+
102+
# Wait for test-bot CI to complete
103+
- name: Wait for test-bot to complete
104+
if: env.UPDATE_NEEDED == 'true' && steps.create-pr.outputs.pull-request-number
105+
run: |
106+
# Wait for CI to start and finish (maximum 30 minutes)
107+
echo "Waiting for test-bot workflow to complete..."
108+
PR_NUMBER=${{ steps.create-pr.outputs.pull-request-number }}
109+
timeout=1800 # 30 minutes in seconds
110+
interval=60 # Check every minute
111+
elapsed=0
112+
113+
while [ $elapsed -lt $timeout ]; do
114+
# Check if test-bot workflow has completed
115+
STATUS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
116+
"https://api.github.com/repos/${{ github.repository }}/actions/runs?status=completed&event=pull_request&head_sha=$(git rev-parse HEAD)")
117+
118+
COMPLETED=$(echo "$STATUS" | jq -r '.workflow_runs[] | select(.name == "brew test-bot") | .status')
119+
120+
if [ "$COMPLETED" = "completed" ]; then
121+
CONCLUSION=$(echo "$STATUS" | jq -r '.workflow_runs[] | select(.name == "brew test-bot") | .conclusion')
122+
if [ "$CONCLUSION" = "success" ]; then
123+
echo "test-bot workflow completed successfully!"
124+
break
125+
elif [ "$CONCLUSION" = "failure" ]; then
126+
echo "test-bot workflow failed!"
127+
exit 1
128+
fi
129+
fi
130+
131+
sleep $interval
132+
elapsed=$((elapsed + interval))
133+
echo "Still waiting... ($elapsed seconds elapsed)"
134+
done
135+
136+
if [ $elapsed -ge $timeout ]; then
137+
echo "Timeout waiting for test-bot workflow to complete"
138+
exit 1
139+
fi
140+
141+
# Add label to trigger pr-pull workflow
142+
- name: Add pr-pull label
143+
if: env.UPDATE_NEEDED == 'true' && steps.create-pr.outputs.pull-request-number
144+
uses: actions/github-script@v6
145+
with:
146+
github-token: ${{ secrets.GITHUB_TOKEN }}
147+
script: |
148+
github.rest.issues.addLabels({
149+
owner: context.repo.owner,
150+
repo: context.repo.repo,
151+
issue_number: ${{ steps.create-pr.outputs.pull-request-number }},
152+
labels: ['pr-pull']
153+
})

.github/workflows/tests.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: [macos-13]
12+
include:
13+
# Intel builds
14+
- os: macos-13
15+
arch: x86_64
16+
- os: macos-14
17+
arch: x86_64
1318
runs-on: ${{ matrix.os }}
14-
timeout-minutes: 30
19+
timeout-minutes: 60 # Increased timeout for ARM builds
1520
steps:
1621
- name: Set up Homebrew
1722
id: set-up-homebrew
@@ -22,9 +27,9 @@ jobs:
2227
uses: actions/cache@v4
2328
with:
2429
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
25-
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
30+
key: ${{ runner.os }}-${{ matrix.arch }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
2631
restore-keys: |
27-
${{ runner.os }}-rubygems-
32+
${{ runner.os }}-${{ matrix.arch }}-rubygems-
2833
2934
- name: Install Homebrew Bundler RubyGems
3035
if: steps.cache.outputs.cache-hit != 'true'
@@ -38,10 +43,12 @@ jobs:
3843

3944
- run: brew test-bot --only-formulae
4045
if: github.event_name == 'pull_request'
46+
env:
47+
HOMEBREW_ARCH: ${{ matrix.arch }}
4148

4249
- name: Upload bottles as artifact
4350
if: always() && github.event_name == 'pull_request'
4451
uses: actions/upload-artifact@v4
4552
with:
46-
name: bottles
53+
name: bottles-${{ matrix.os }}-${{ matrix.arch }}
4754
path: '*.bottle.*'

0 commit comments

Comments
 (0)