@@ -2,12 +2,14 @@ name: Periodic Gateway Build
22
33on :
44 schedule :
5- - cron : ' */30 * * * *' # run every 30 minutes
5+ - cron : ' 0 * * * *' # run every hour at the top of the hour
66 workflow_dispatch :
77
88jobs :
99 hourly-build :
1010 runs-on : ubuntu-latest
11+ env :
12+ BUILDX_BUILDER : docker-container
1113 steps :
1214 - name : Checkout repository
1315 uses : actions/checkout@v4
@@ -17,45 +19,199 @@ jobs:
1719 with :
1820 go-version : ' 1.25'
1921
22+ - name : Cache Go modules
23+ uses : actions/cache@v4
24+ with :
25+ path : |
26+ ~/.cache/go-build
27+ ~/go/pkg/mod
28+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29+ restore-keys : |
30+ ${{ runner.os }}-go-
31+
2032 - name : Set up Docker Buildx
2133 uses : docker/setup-buildx-action@v3
2234 with :
23- install : true
2435 driver : docker-container
2536
2637 - name : Build gateway
2738 working-directory : ./gateway
2839 run : |
29- set -e
30- make build
40+ set -o pipefail
41+ : > "$GITHUB_WORKSPACE/gateway-build.log"
42+ (set -o pipefail; make build) 2>&1 | tee "$GITHUB_WORKSPACE/gateway-build.log"
43+ rc=${PIPESTATUS[0]}
44+ if [ "$rc" -ne 0 ]; then
45+ echo "gateway build failed (rc=$rc), see $GITHUB_WORKSPACE/gateway-build.log" >&2
46+ exit $rc
47+ fi
3148
3249 - name : Build CLI
3350 working-directory : ./cli/src
3451 run : |
35- set -e
36- make build-all
52+ set -o pipefail
53+ : > "$GITHUB_WORKSPACE/cli-build.log"
54+ (set -o pipefail; make build-all) 2>&1 | tee "$GITHUB_WORKSPACE/cli-build.log"
55+ rc=${PIPESTATUS[0]}
56+ if [ "$rc" -ne 0 ]; then
57+ echo "cli build failed (rc=$rc), see $GITHUB_WORKSPACE/cli-build.log" >&2
58+ exit $rc
59+ fi
3760
3861 - name : Prepare my-gw run directory
3962 run : |
40- set -e
41- rm -rf my-gw
42- mkdir my-gw
43- # Copy the linux amd64 binary produced by build-all to my-gw and name it `ap`
44- if [ -f cli/src/build/ap-linux-amd64 ]; then
45- cp cli/src/build/ap-linux-amd64 my-gw/ap
46- elif [ -f cli/src/build/ap-linux-amd64-v* ]; then
47- # handle versioned outputs if present
48- cp cli/src/build/ap-linux-amd64-v* my-gw/ap || true
49- else
50- echo "Warning: expected CLI binary not found at cli/src/build/ap-linux-amd64"
63+ set -o pipefail
64+ : > "$GITHUB_WORKSPACE/prepare-dir.log"
65+ (set -o pipefail; \
66+ rm -rf my-gw; \
67+ mkdir my-gw; \
68+ # Copy the linux amd64 binary produced by build-all to my-gw and name it `ap`; handle variants
69+ if [ -f cli/src/build/ap-linux-amd64 ]; then \
70+ cp cli/src/build/ap-linux-amd64 my-gw/ap; \
71+ elif ls cli/src/build/ap-linux-amd64-v* 1> /dev/null 2>&1; then \
72+ cp cli/src/build/ap-linux-amd64-v* my-gw/ap; \
73+ else \
74+ echo "Error: expected CLI binary not found at cli/src/build/ap-linux-amd64"; \
75+ exit 1; \
76+ fi; \
77+ chmod +x my-gw/ap || true; \
78+ # Copy the sample manifest into the run directory if it exists
79+ if [ -f cli/src/tests/resources/simple-policy-manifest.yaml ]; then \
80+ cp cli/src/tests/resources/simple-policy-manifest.yaml my-gw/policy-manifest.yaml; \
81+ fi) 2>&1 | tee "$GITHUB_WORKSPACE/prepare-dir.log"
82+ rc=${PIPESTATUS[0]}
83+ if [ "$rc" -ne 0 ]; then
84+ echo "prepare-dir failed (rc=$rc), see $GITHUB_WORKSPACE/prepare-dir.log" >&2
85+ exit $rc
5186 fi
52- chmod +x my-gw/ap || true
53- # Copy the sample manifest into the run directory if it exists
54- if [ -f cli/src/tests/resources/simple-policy-manifest.yaml ]; then
55- # copy and rename to policy-manifest.yaml as expected by the build
56- cp cli/src/tests/resources/simple-policy-manifest.yaml my-gw/policy-manifest.yaml
87+
88+ - name : Run ap gateway image build (smoke test)
89+ working-directory : ./my-gw
90+ env :
91+ CI : " "
92+ WSO2AP_GW_USERNAME : ${{ secrets.WSO2AP_GW_USERNAME || '' }}
93+ WSO2AP_GW_PASSWORD : ${{ secrets.WSO2AP_GW_PASSWORD || '' }}
94+ run : |
95+ set -o pipefail
96+ : > "$GITHUB_WORKSPACE/ap-gateway-image-build.log"
97+ # ensure docker log directory exists in runner home so the build can write into it
98+ mkdir -p "$HOME/.wso2ap/.tmp/gateway-image-build/logs"
99+ (set -o pipefail; \
100+ if [ ! -x ./ap ]; then \
101+ echo "ap binary not present or not executable; skipping smoke run"; \
102+ exit 0; \
103+ fi; \
104+ ./ap gateway image build) 2>&1 | tee "$GITHUB_WORKSPACE/ap-gateway-image-build.log"
105+ rc=${PIPESTATUS[0]}
106+ # copy docker.log from runner home into workspace for upload
107+ mkdir -p "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs"
108+ if [ -f "$HOME/.wso2ap/.tmp/gateway-image-build/logs/docker.log" ]; then
109+ cp "$HOME/.wso2ap/.tmp/gateway-image-build/logs/docker.log" "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs/docker.log" || true
110+ fi
111+ if [ "$rc" -ne 0 ]; then
112+ echo "ap gateway image build failed (rc=$rc), see $GITHUB_WORKSPACE/ap-gateway-image-build.log and docker.log" >&2
113+ exit $rc
57114 fi
58115
116+ - name : Ensure log files exist (placeholders)
117+ run : |
118+ mkdir -p "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs"
119+ touch "$GITHUB_WORKSPACE/gateway-build.log" || true
120+ touch "$GITHUB_WORKSPACE/cli-build.log" || true
121+ touch "$GITHUB_WORKSPACE/prepare-dir.log" || true
122+ touch "$GITHUB_WORKSPACE/ap-gateway-image-build.log" || true
123+ touch "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs/docker.log" || true
124+
125+ - name : Upload gateway-build.log
126+ uses : actions/upload-artifact@v4
127+ with :
128+ name : gateway-build.log
129+ path : gateway-build.log
130+
131+ - name : Upload cli-build.log
132+ uses : actions/upload-artifact@v4
133+ with :
134+ name : cli-build.log
135+ path : cli-build.log
136+
137+ - name : Upload prepare-dir.log
138+ uses : actions/upload-artifact@v4
139+ with :
140+ name : prepare-dir.log
141+ path : prepare-dir.log
142+
143+ - name : Upload ap-gateway-image-build.log
144+ uses : actions/upload-artifact@v4
145+ with :
146+ name : ap-gateway-image-build.log
147+ path : ap-gateway-image-build.log
148+
149+ - name : Upload docker.log
150+ uses : actions/upload-artifact@v4
151+ with :
152+ name : docker.log
153+ path : .wso2ap/.tmp/gateway-image-build/logs/docker.log
154+ name : Periodic Gateway Build
155+
156+ on :
157+ schedule :
158+ - cron : ' 0 * * * *' # run every hour at the top of the hour
159+ workflow_dispatch :
160+
161+ jobs :
162+ hourly-build :
163+ runs-on : ubuntu-latest
164+ steps :
165+ - name : Checkout repository
166+ uses : actions/checkout@v4
167+
168+ - name : Set up Go
169+ uses : actions/setup-go@v5
170+ with :
171+ go-version : ' 1.25'
172+
173+ - name : Set up Docker Buildx
174+ uses : docker/setup-buildx-action@v3
175+ with :
176+ install : true
177+ driver : docker-container
178+
179+ - name : Build gateway
180+ working-directory : ./gateway
181+ run : |
182+ set -o pipefail
183+ # ensure log file exists and capture all output
184+ : > "$GITHUB_WORKSPACE/gateway-build.log"
185+ (set -o pipefail; make build) 2>&1 | tee "$GITHUB_WORKSPACE/gateway-build.log" || true
186+
187+ - name : Build CLI
188+ working-directory : ./cli/src
189+ run : |
190+ set -o pipefail
191+ : > "$GITHUB_WORKSPACE/cli-build.log"
192+ (set -o pipefail; make build-all) 2>&1 | tee "$GITHUB_WORKSPACE/cli-build.log" || true
193+
194+ - name : Prepare my-gw run directory
195+ run : |
196+ set -o pipefail
197+ : > "$GITHUB_WORKSPACE/prepare-dir.log"
198+ (set -o pipefail; \
199+ rm -rf my-gw; \
200+ mkdir my-gw; \
201+ # Copy the linux amd64 binary produced by build-all to my-gw and name it `ap`; handle variants
202+ if [ -f cli/src/build/ap-linux-amd64 ]; then \
203+ cp cli/src/build/ap-linux-amd64 my-gw/ap; \
204+ elif ls cli/src/build/ap-linux-amd64-v* 1> /dev/null 2>&1; then \
205+ cp cli/src/build/ap-linux-amd64-v* my-gw/ap || true; \
206+ else \
207+ echo "Warning: expected CLI binary not found at cli/src/build/ap-linux-amd64"; \
208+ fi; \
209+ chmod +x my-gw/ap || true; \
210+ # Copy the sample manifest into the run directory if it exists
211+ if [ -f cli/src/tests/resources/simple-policy-manifest.yaml ]; then \
212+ cp cli/src/tests/resources/simple-policy-manifest.yaml my-gw/policy-manifest.yaml; \
213+ fi) 2>&1 | tee "$GITHUB_WORKSPACE/prepare-dir.log" || true
214+
59215 - name : Run ap gateway image build (smoke test)
60216 working-directory : ./my-gw
61217 env :
@@ -65,12 +221,54 @@ jobs:
65221 WSO2AP_GW_USERNAME : ${{ secrets.WSO2AP_GW_USERNAME || '' }}
66222 WSO2AP_GW_PASSWORD : ${{ secrets.WSO2AP_GW_PASSWORD || '' }}
67223 run : |
68- set -eux
69- if [ ! -x ./ap ]; then
70- echo "ap binary not present or not executable; skipping smoke run"
71- exit 0
72- fi
73- # Run the command and capture output
74- ./ap gateway image build 2>&1 | tee build.log || true
75- # Verify the build printed the workspace-cleared note
76- grep -q "Note: Workspace may be cleared on the next run of this command." build.log
224+ set -o pipefail
225+ : > "$GITHUB_WORKSPACE/ap-gateway-image-build.log"
226+ # ensure docker log directory exists so the build can write into it
227+ mkdir -p "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs"
228+ (set -o pipefail; \
229+ if [ ! -x ./ap ]; then \
230+ echo "ap binary not present or not executable; skipping smoke run"; \
231+ exit 0; \
232+ fi; \
233+ ./ap gateway image build) 2>&1 | tee "$GITHUB_WORKSPACE/ap-gateway-image-build.log" || true
234+ # optional verification: check for workspace-cleared note (non-fatal)
235+ grep -q "Note: Workspace may be cleared on the next run of this command." "$GITHUB_WORKSPACE/ap-gateway-image-build.log" || true
236+
237+ - name : Ensure log files exist (placeholders)
238+ run : |
239+ mkdir -p "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs"
240+ touch "$GITHUB_WORKSPACE/gateway-build.log" || true
241+ touch "$GITHUB_WORKSPACE/cli-build.log" || true
242+ touch "$GITHUB_WORKSPACE/prepare-dir.log" || true
243+ touch "$GITHUB_WORKSPACE/ap-gateway-image-build.log" || true
244+ touch "$GITHUB_WORKSPACE/.wso2ap/.tmp/gateway-image-build/logs/docker.log" || true
245+
246+ - name : Upload gateway-build.log
247+ uses : actions/upload-artifact@v4
248+ with :
249+ name : gateway-build.log
250+ path : gateway-build.log
251+
252+ - name : Upload cli-build.log
253+ uses : actions/upload-artifact@v4
254+ with :
255+ name : cli-build.log
256+ path : cli-build.log
257+
258+ - name : Upload prepare-dir.log
259+ uses : actions/upload-artifact@v4
260+ with :
261+ name : prepare-dir.log
262+ path : prepare-dir.log
263+
264+ - name : Upload ap-gateway-image-build.log
265+ uses : actions/upload-artifact@v4
266+ with :
267+ name : ap-gateway-image-build.log
268+ path : ap-gateway-image-build.log
269+
270+ - name : Upload docker.log
271+ uses : actions/upload-artifact@v4
272+ with :
273+ name : docker.log
274+ path : .wso2ap/.tmp/gateway-image-build/logs/docker.log
0 commit comments