Skip to content

Commit 2ccc85f

Browse files
committed
Initial commit
0 parents  commit 2ccc85f

File tree

1 file changed

+241
-0
lines changed

1 file changed

+241
-0
lines changed

ci.yml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
name: Build and test
2+
on:
3+
workflow_call:
4+
inputs:
5+
cygport_file:
6+
description: Path to the cygport file
7+
required: true
8+
type: string
9+
bootstrap_packages:
10+
description: Cygwin packages required to parse the cygport file
11+
required: false
12+
type: string
13+
default: cygport
14+
bootstrap_package_install_timeout:
15+
description: Time in minutes to allow for the Cygwin bootstrap install
16+
required: false
17+
type: integer
18+
default: 360
19+
required_package_install_timeout:
20+
description: Time in minutes to allow for the Cygwin build dependency install
21+
required: false
22+
type: integer
23+
default: 360
24+
cygport_download_timeout:
25+
description: Time in minutes to allow for the `cygport download` stage
26+
required: false
27+
type: integer
28+
default: 360
29+
cygport_prep_timeout:
30+
description: Time in minutes to allow for the `cygport prep` stage
31+
required: false
32+
type: integer
33+
default: 360
34+
cygport_compile_timeout:
35+
description: Time in minutes to allow for the `cygport compile` stage
36+
required: false
37+
type: integer
38+
default: 360
39+
cygport_test_timeout:
40+
description: Time in minutes to allow for the `cygport test` stage
41+
required: false
42+
type: integer
43+
default: 360
44+
cygport_install_timeout:
45+
description: Time in minutes to allow for the `cygport install` stage
46+
required: false
47+
type: integer
48+
default: 360
49+
cygport_package_timeout:
50+
description: Time in minutes to allow for the `cygport package` stage
51+
required: false
52+
type: integer
53+
default: 360
54+
55+
jobs:
56+
build-test:
57+
name: Build and test
58+
runs-on: windows-latest
59+
steps:
60+
61+
- name: Configure Git for Windows' core.autocrlf
62+
run: git config --global core.autocrlf input
63+
timeout-minutes: 1
64+
65+
- name: Checkout
66+
uses: actions/checkout@v3
67+
timeout-minutes: 1
68+
69+
# In the name of speed, pull packages from a previous cache on GitHub's
70+
# servers if one exists, rather than hitting the Cygwin mirrors.
71+
#
72+
# Ideally we'd cache the actual Cygwin installation, to avoid the need to
73+
# unpack and install the packages, as well as the need to download them,
74+
# but the cache action uses Git tar, which copes poorly with the symlinks
75+
# in the Cygwin installation directory, and there's a bootstrap problem
76+
# with using Cygwin's tar for that purpose!
77+
#
78+
# We always want to update the cache, as there might have been package
79+
# updates since the previous store was cached, so use the trick from [0]
80+
# to ensure that happens.
81+
# [0]: https://github.com/actions/cache/blob/6fd2d4538ca777f67fccddb233cf1a8ff1339012/tips-and-workarounds.md#update-a-cache
82+
- name: Use Cygwin package cache
83+
uses: actions/cache/restore@v3
84+
with:
85+
key: cygwin-packages-${{ github.run_id }}-${{ github.run_attempt }}
86+
path: 'C:\cygwin-packages'
87+
restore-keys: |
88+
cygwin-packages-${{ github.run_id }}-
89+
cygwin-packages-
90+
91+
# Compute a checksum for the current package cache, so we can check if we
92+
# need to store a new cache, rather than filling the cache with identical
93+
# stores.
94+
- name: Compute package cache checksum
95+
working-directory: 'C:\'
96+
shell: bash
97+
run: |
98+
if [[ -d cygwin-packages ]]; then
99+
find cygwin-packages -type f '!' -name setup.ini -print0 |
100+
sort -z |
101+
xargs -0 b2sum >cygwin-package-checksum.old
102+
fi
103+
timeout-minutes: 1
104+
105+
- name: Install bootstrap packages
106+
id: install-bootstrap
107+
uses: cygwin/cygwin-install-action@db475590d56881c6cef7b3f96f6f3dd9532ea1f4
108+
with:
109+
packages: ${{ inputs.bootstrap_packages }}
110+
add-to-path: false
111+
timeout-minutes: ${{ inputs.bootstrap_package_install_timeout }}
112+
113+
- name: Load build requirements from cygport file
114+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
115+
env:
116+
PATH: C:\cygwin\bin
117+
run: |
118+
eval "$(cygport "${{ inputs.cygport_file }}" vars NAME PF ARCH BUILD_REQUIRES)"
119+
printf 'CYGPORT_NAME=%s\n' "$NAME" >>"$GITHUB_ENV"
120+
printf 'CYGPORT_PF=%s\n' "$PF" >>"$GITHUB_ENV"
121+
printf 'CYGPORT_ARCH=%s\n' "$ARCH" >>"$GITHUB_ENV"
122+
printf 'CYGPORT_BUILD_REQUIRES=%s\n' "$BUILD_REQUIRES" >>"$GITHUB_ENV"
123+
timeout-minutes: 1
124+
125+
- name: Install Cygwin build requirements
126+
id: install-build-reqs
127+
uses: cygwin/cygwin-install-action@db475590d56881c6cef7b3f96f6f3dd9532ea1f4
128+
with:
129+
packages: ${{ env.CYGPORT_BUILD_REQUIRES }}
130+
add-to-path: false
131+
timeout-minutes: ${{ inputs.required_package_install_timeout }}
132+
133+
# Check if the package downloads have changed if there's any chance we've
134+
# managed to reasonably update them.
135+
- name: Check if package cache needs updating
136+
if: always() && steps.install-bootstrap.outcome == 'success'
137+
working-directory: 'C:\'
138+
shell: bash
139+
run: |
140+
if [[ -d cygwin-packages ]]; then
141+
find cygwin-packages -type f '!' -name setup.ini -print0 |
142+
sort -z |
143+
xargs -0 b2sum >cygwin-package-checksum.new
144+
if ! diff cygwin-package-checksum.old cygwin-package-checksum.new; then
145+
printf 'UPDATE_CYGWIN_PACKAGE_CACHE=YesPlease' >>"$GITHUB_ENV"
146+
fi
147+
fi
148+
timeout-minutes: 1
149+
150+
- name: Store package cache
151+
if: always() && env.UPDATE_CYGWIN_PACKAGE_CACHE == 'YesPlease'
152+
uses: actions/cache/save@v3
153+
with:
154+
key: cygwin-packages-${{ github.run_id }}-${{ github.run_attempt }}
155+
path: 'C:\cygwin-packages'
156+
timeout-minutes: 1
157+
158+
- name: Generate cygcheck output
159+
if: always() && steps.install-bootstrap.outcome == 'success'
160+
run: C:\cygwin\bin\cygcheck.exe -srv >C:\cygwin\var\log\cygcheck.out
161+
timeout-minutes: 5
162+
163+
- name: Store Cygwin logs
164+
if: always() && (steps.install-bootstrap.outcome == 'success' || steps.install-bootstrap.outcome == 'failure')
165+
uses: actions/upload-artifact@v3
166+
with:
167+
name: cygwin-logs
168+
path: 'C:\cygwin\var\log\'
169+
timeout-minutes: 5
170+
171+
- name: Cygport download
172+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
173+
env:
174+
PATH: C:\cygwin\bin
175+
run: cygport "${{ inputs.cygport_file }}" download
176+
timeout-minutes: ${{ inputs.cygport_download_timeout }}
177+
178+
- name: Cygport prep
179+
id: cygport-prep
180+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
181+
env:
182+
PATH: C:\cygwin\bin
183+
run: cygport "${{ inputs.cygport_file }}" prep
184+
timeout-minutes: ${{ inputs.cygport_prep_timeout }}
185+
186+
- name: Cygport compile
187+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
188+
env:
189+
PATH: C:\cygwin\bin
190+
run: cygport "${{ inputs.cygport_file }}" compile
191+
timeout-minutes: ${{ inputs.cygport_compile_timeout }}
192+
193+
- name: Cygport test
194+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
195+
env:
196+
PATH: C:\cygwin\bin
197+
run: cygport "${{ inputs.cygport_file }}" test
198+
timeout-minutes: ${{ inputs.cygport_test_timeout }}
199+
200+
- name: Cygport install
201+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
202+
env:
203+
PATH: C:\cygwin\bin
204+
run: cygport "${{ inputs.cygport_file }}" install
205+
timeout-minutes: ${{ inputs.cygport_install_timeout }}
206+
207+
- name: Cygport package
208+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
209+
env:
210+
PATH: C:\cygwin\bin
211+
run: cygport "${{ inputs.cygport_file }}" package
212+
timeout-minutes: ${{ inputs.cygport_package_timeout }}
213+
214+
- name: Tar up build results
215+
if: always()
216+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0}
217+
env:
218+
PATH: C:\cygwin\bin
219+
run: tar -cvf build-results.tar "${CYGPORT_PF}.${ARCH}/"
220+
timeout-minutes: 10
221+
222+
- name: Store build results
223+
if: always() && steps.cygport-prep.outcome == 'success'
224+
uses: actions/upload-artifact@v3
225+
with:
226+
name: build-results
227+
path: build-results.tar
228+
if-no-files-found: error
229+
timeout-minutes: 5
230+
231+
# Artifacts are great for letting me download the files, and passing
232+
# files between jobs in the same action, but not for passing files
233+
# between actions. Cache the build results so they can be used by a
234+
# separate release action.
235+
- name: Cache build results
236+
if: startsWith(github.ref, 'refs/heads/')
237+
uses: actions/cache/save@v3
238+
with:
239+
key: ${{ env.CYGPORT_NAME }}-build-${{ github.ref_name }}-${{ github.sha }}
240+
path: build-results.tar
241+
timeout-minutes: 5

0 commit comments

Comments
 (0)