Skip to content

Commit f01b8ee

Browse files
authored
Merge pull request #37 from openmoq/fix-ubuntu-tarball-name
setup-deps-tarball: use amd64 arch suffix for ubuntu
2 parents 13280ec + 80e7fc7 commit f01b8ee

4 files changed

Lines changed: 204 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: build
22

33
on:
44
pull_request:
@@ -55,3 +55,54 @@ jobs:
5555
name: "test (${{ matrix.name }})"
5656
path: ${{ matrix.build_dir }}/test-results.xml
5757
reporter: java-junit
58+
59+
notify-failure:
60+
runs-on: ubuntu-22.04
61+
needs: [build]
62+
if: failure()
63+
steps:
64+
- name: Notify Slack
65+
continue-on-error: true
66+
env:
67+
GH_TOKEN: ${{ github.token }}
68+
SLACK_WEBHOOK_URL: ${{ secrets.OMOQ_SLACK_WEBHOOK_URL }}
69+
run: |
70+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
71+
if [ "${{ github.event_name }}" = "pull_request" ]; then
72+
# First-failure-only: skip if previous run on this branch also failed
73+
PREV=$(gh api \
74+
"repos/${{ github.repository }}/actions/workflows/ci.yml/runs?branch=${{ github.head_ref }}&event=pull_request&per_page=2" \
75+
--jq '.workflow_runs[1].conclusion // "none"' 2>/dev/null) || PREV="none"
76+
if [ "$PREV" = "failure" ]; then
77+
echo "Previous run also failed — skipping"
78+
exit 0
79+
fi
80+
TEXT=":x: *${{ github.repository }}* \`${{ github.head_ref }}\` failed — <${{ github.event.pull_request.html_url }}|PR #${{ github.event.pull_request.number }}> · <${RUN_URL}|run> · <${{ github.event.pull_request.html_url }}/checks|tests>"
81+
else
82+
SHORT="${GITHUB_SHA:0:12}"
83+
TEXT=":x: *${{ github.repository }}* \`${{ github.ref_name }}\` \`${SHORT}\` — build failed · <${RUN_URL}|run>"
84+
fi
85+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
86+
-H "Content-Type: application/json" \
87+
--data "{\"text\": \"${TEXT}\"}"
88+
89+
- name: Notify email (main only)
90+
if: github.event_name == 'push'
91+
continue-on-error: true
92+
env:
93+
AWS_ACCESS_KEY_ID: ${{ secrets.OMOQ_AWS_ACCESS_KEY_ID }}
94+
AWS_SECRET_ACCESS_KEY: ${{ secrets.OMOQ_AWS_SECRET_ACCESS_KEY }}
95+
AWS_DEFAULT_REGION: us-east-1
96+
run: |
97+
SHORT="${GITHUB_SHA:0:12}"
98+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
99+
REPO_NAME="${{ github.event.repository.name }}"
100+
SUBJECT="[${REPO_NAME}] build FAILED ${{ github.ref_name }} ${SHORT}"
101+
BODY="${{ github.repository }} · ${{ github.ref_name }} · ${SHORT}\n${RUN_URL}"
102+
aws ses send-email \
103+
--from "noreply@ci.openmoq.org" \
104+
--destination '{"ToAddresses":["github-notifications@openmoq.org"]}' \
105+
--message "{
106+
\"Subject\": {\"Data\": \"$SUBJECT\"},
107+
\"Body\": {\"Text\": {\"Data\": \"$BODY\"}}
108+
}"

.github/workflows/publish.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: publish release
2+
3+
# Builds o-rly on each target platform and publishes per-architecture
4+
# artifact tarballs as a GitHub Release keyed by commit SHA.
5+
6+
on:
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
packages: write # reserved for future Docker image publishing
14+
15+
jobs:
16+
build:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- name: ubuntu-22.04-amd64
22+
runner: ubuntu-22.04
23+
24+
name: ${{ matrix.name }}
25+
runs-on: ${{ matrix.runner }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
submodules: true
31+
32+
- name: Install system dependencies
33+
run: bash deps/moxygen/standalone/install-system-deps.sh
34+
35+
- name: Download moxygen release tarball
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
run: bash scripts/setup-deps-tarball.sh
39+
40+
- name: Set up ccache
41+
uses: hendrikmuhs/ccache-action@v1
42+
with:
43+
key: publish-${{ matrix.name }}
44+
max-size: 500M
45+
46+
- name: Configure
47+
run: |
48+
cmake -S . -B _build --preset default \
49+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
50+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
51+
-DCMAKE_PREFIX_PATH="$(cat .scratch/cmake_prefix_path.txt)" \
52+
-DBUILD_TESTING=OFF
53+
54+
- name: Build
55+
run: cmake --build _build -j$(nproc)
56+
57+
- name: Install
58+
run: cmake --install _build --prefix "$GITHUB_WORKSPACE/install"
59+
60+
- name: Package
61+
id: package
62+
run: |
63+
ARTIFACT="${{ github.event.repository.name }}-${{ matrix.name }}.tar.gz"
64+
tar czf "$ARTIFACT" -C "$GITHUB_WORKSPACE/install" .
65+
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
66+
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: ${{ steps.package.outputs.artifact }}
71+
path: ${{ steps.package.outputs.artifact }}
72+
retention-days: 90
73+
74+
release:
75+
runs-on: ubuntu-22.04
76+
needs: [build]
77+
if: always()
78+
steps:
79+
- uses: actions/checkout@v4
80+
if: needs.build.result == 'success'
81+
82+
- name: Download all artifacts
83+
if: needs.build.result == 'success'
84+
uses: actions/download-artifact@v4
85+
with:
86+
path: artifacts/
87+
88+
- name: Create release
89+
if: needs.build.result == 'success'
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
SHORT="${GITHUB_SHA:0:12}"
94+
TAG="build-${SHORT}"
95+
gh release create "$TAG" artifacts/**/* \
96+
--repo "${{ github.repository }}" \
97+
--title "build ${SHORT}" \
98+
--notes "Automated release from \`${{ github.ref_name }}\` at \`${SHORT}\`."
99+
100+
# Prune old releases, keep 20
101+
gh api "repos/${{ github.repository }}/releases" \
102+
--jq 'sort_by(.created_at) | reverse | .[20:] | .[].tag_name' \
103+
| while read -r tag; do
104+
gh release delete "$tag" --repo "${{ github.repository }}" --yes --cleanup-tag 2>/dev/null || true
105+
done
106+
107+
- name: Notify Slack
108+
if: always()
109+
continue-on-error: true
110+
env:
111+
SLACK_WEBHOOK_URL: ${{ secrets.OMOQ_SLACK_WEBHOOK_URL }}
112+
run: |
113+
SHORT="${GITHUB_SHA:0:12}"
114+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
115+
if [ "${{ needs.build.result }}" = "success" ]; then
116+
REL_URL="${{ github.server_url }}/${{ github.repository }}/releases/tag/build-${SHORT}"
117+
TEXT=":white_check_mark: *${{ github.repository }}* \`${{ github.ref_name }}\` \`${SHORT}\` — <${REL_URL}|release> · <${RUN_URL}|run>"
118+
else
119+
TEXT=":x: *${{ github.repository }}* \`${{ github.ref_name }}\` \`${SHORT}\` — build failed · <${RUN_URL}|run>"
120+
fi
121+
curl -s -X POST "$SLACK_WEBHOOK_URL" \
122+
-H "Content-Type: application/json" \
123+
--data "{\"text\": \"${TEXT}\"}"
124+
125+
- name: Notify email
126+
if: always()
127+
continue-on-error: true
128+
env:
129+
AWS_ACCESS_KEY_ID: ${{ secrets.OMOQ_AWS_ACCESS_KEY_ID }}
130+
AWS_SECRET_ACCESS_KEY: ${{ secrets.OMOQ_AWS_SECRET_ACCESS_KEY }}
131+
AWS_DEFAULT_REGION: us-east-1
132+
run: |
133+
SHORT="${GITHUB_SHA:0:12}"
134+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
135+
REPO_NAME="${{ github.event.repository.name }}"
136+
RESULT="${{ needs.build.result }}"
137+
JOB_STATUS="${{ job.status }}"
138+
if [ "$RESULT" = "success" ] && [ "$JOB_STATUS" = "success" ]; then
139+
SUBJECT="[${REPO_NAME}] published ${{ github.ref_name }} ${SHORT}"
140+
else
141+
SUBJECT="[${REPO_NAME}] build FAILED ${{ github.ref_name }} ${SHORT}"
142+
fi
143+
BODY="${{ github.repository }} · ${{ github.ref_name }} · ${SHORT}\n${RUN_URL}"
144+
aws ses send-email \
145+
--from "noreply@ci.openmoq.org" \
146+
--destination '{"ToAddresses":["github-notifications@openmoq.org"]}' \
147+
--message "{
148+
\"Subject\": {\"Data\": \"$SUBJECT\"},
149+
\"Body\": {\"Text\": {\"Data\": \"$BODY\"}}
150+
}"

scripts/setup-deps-tarball.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ detect_platform() {
4545
local darch="${arch/x86_64/amd64}"
4646
darch="${darch/aarch64/arm64}"
4747
case "$ID" in
48-
ubuntu) echo "ubuntu-${VERSION_ID}-${arch}" ;;
48+
ubuntu) echo "ubuntu-${VERSION_ID}-${darch}" ;;
4949
debian) echo "bookworm-${darch}" ;;
5050
*)
5151
echo "Error: unsupported Linux distro: $ID" >&2

0 commit comments

Comments
 (0)