-
Notifications
You must be signed in to change notification settings - Fork 8
164 lines (146 loc) · 5.48 KB
/
Copy pathmain.yml
File metadata and controls
164 lines (146 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
on:
push:
branches: ["main"]
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch:
jobs:
define-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.packages.outputs.packages }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
clean: false
- name: Discover changed packages
id: packages
run: |
case "${{ github.event_name }}" in
"push")
base_ref="${{ github.event.before }}"
;;
"pull_request")
base_ref="${{ github.event.pull_request.base.sha }}"
;;
*)
base_ref=""
;;
esac
packages=$(scripts/discover-changed-packages.sh "${{ github.event_name }}" "$base_ref")
echo "packages=$packages" >> "$GITHUB_OUTPUT"
build-verify-publish:
permissions:
contents: read
packages: read
id-token: write
runs-on: ubuntu-latest
env:
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
FBRK_LOG_DIR: ${{ github.workspace }}/${{ matrix.package }}/.ato/logs
needs: define-packages
if: needs.define-packages.outputs.packages != '[]'
strategy:
matrix:
package: ${{ fromJSON(needs.define-packages.outputs.packages) }}
fail-fast: false
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
clean: false
- uses: atopile/setup-atopile@v2
# Uses Docker image from atopile/monopile#1400 (SIGILL fix)
# TODO: Revert to docker-tag: main once PR is merged
with:
docker-tag: pr-1400
- name: Print atopile + KiCad versions
run: |
set -euo pipefail
echo "ato version: $(ato --version)"
echo "ato githash: $(docker image inspect atopile-local --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}')"
echo "kicad version: $(docker run --rm --entrypoint kicad-cli atopile-local --version)"
- run: ato sync
working-directory: ${{ matrix.package }}
- run: ato build ${{ matrix.package }} -t all
env:
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
# Temporarily disable frozen mode to allow layout updates after net naming fix
# TODO: Remove ATO_FROZEN=0 once layouts are regenerated with the fixed atopile
ATO_FROZEN: "0"
- run: ato package verify -s
working-directory: ${{ matrix.package }}
- name: Publish dry run
if: ${{ !(github.event_name == 'push' && github.ref == 'refs/heads/main') }}
env:
ATO_CLI_PACKAGE_SKIP_DUPLICATE_VERSIONS: "true"
NONINTERACTIVE: "1"
run: ato package publish --dry-run ${{ matrix.package }}
- name: Publish package
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
ATO_CLI_PACKAGE_SKIP_DUPLICATE_VERSIONS: "true"
NONINTERACTIVE: "1"
run: |
for attempt in 1 2 3; do
echo "Publish attempt $attempt/3..."
if ato package publish ${{ matrix.package }}; then
echo "Publish succeeded on attempt $attempt"
exit 0
fi
echo "Attempt $attempt failed, retrying in 15s..."
sleep 15
done
echo "All publish attempts failed"
exit 1
- name: Print errors and warnings on failure
if: failure()
run: |
pkg="${{ matrix.package }}"
echo "::group::Error Logs"
find "$pkg/build/logs" -name "*.error.log" -size +0 -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true
echo "::endgroup::"
echo "::group::Warning Logs"
find "$pkg/build/logs" -name "*.warning.log" -size +0 -exec echo "=== {} ===" \; -exec cat {} \; 2>/dev/null || true
echo "::endgroup::"
- name: Archive build logs
id: archive_logs
if: always()
run: |
pkg="${{ matrix.package }}"
logs_dir="$pkg/build/logs"
mkdir -p artifacts
safe_pkg=$(echo "$pkg" | tr '/' '-')
artifact_name="build-logs-$safe_pkg-${{ github.run_id }}-${{ github.run_attempt }}"
archive="artifacts/$artifact_name.zip"
if [ -d "$logs_dir" ]; then
zip -r "$archive" "$logs_dir" -q
echo "archive_path=$archive" >> "$GITHUB_OUTPUT"
echo "artifact_name=$artifact_name" >> "$GITHUB_OUTPUT"
else
echo "No logs directory at $logs_dir"
echo "archive_path=" >> "$GITHUB_OUTPUT"
echo "artifact_name=" >> "$GITHUB_OUTPUT"
fi
- name: Upload build logs
if: always() && steps.archive_logs.outputs.archive_path != ''
uses: actions/upload-artifact@v4
with:
name: ${{ steps.archive_logs.outputs.artifact_name }}
path: ${{ steps.archive_logs.outputs.archive_path }}
if-no-files-found: warn
retention-days: 14
verify-matrix:
runs-on: ubuntu-latest
needs: [build-verify-publish]
if: always()
steps:
- name: Fail if any matrix job failed
run: |
echo "matrix result: ${{ needs.build-verify-publish.result }}"
if [ "${{ needs.build-verify-publish.result }}" != "success" ] && [ "${{ needs.build-verify-publish.result }}" != "skipped" ]; then
echo "One or more matrix jobs failed."
exit 1
fi
echo "All matrix jobs passed."