@@ -16,107 +16,276 @@ on:
1616 pull_request :
1717
1818jobs :
19+ Fetch-Source :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Determine Target Branches
23+ id : gittargets
24+ shell : bash
25+ run : |
26+ # Always use master for testing unless it is the testing repo
27+ if [[ $GITHUB_REPOSITORY == apache/incubator-nuttx-testing ]]
28+ then
29+ TESTING_REF=""
30+ else
31+ TESTING_REF="master"
32+ fi
33+ OS_REF=""
34+ APPS_REF=""
35+
36+ REF=$GITHUB_REF
37+
38+ # If a base ref is set this is a PR and we will want to use
39+ # the base ref instead of the ref that triggered the event
40+ if [ ${GITHUB_BASE_REF} ]; then
41+ REF=refs/heads/$GITHUB_BASE_REF
42+ fi
43+
44+ echo "Working with ref: $REF"
45+
46+ # We modify for all tags and release branches
47+ if [[ $REF =~ refs/heads/releases/*|refs/tags/* ]]; then
48+ if [[ $REF =~ refs/heads/* ]]
49+ then
50+ REF_NAME=${REF##refs/heads/}
51+ echo "Working with a branch: $REF_NAME"
52+ else
53+ REF_NAME=${REF##refs/tags/}
54+ echo "Working with a tag: $REF_NAME"
55+ fi
56+
57+ # Determine the repo and leave that unset to use the normal checkout behavior
58+ # of using the merge commit instead of HEAD
59+ case $GITHUB_REPOSITORY in
60+ "apache/incubator-nuttx")
61+ # OS
62+ echo "Triggered by change in OS"
63+ APPS_REF=$REF_NAME
64+ ;;
65+
66+ "apache/incubator-nuttx-apps" )
67+ # APPS
68+ OS_REF=$REF_NAME
69+ echo "Triggered by change in APPS"
70+ ;;
71+
72+ *)
73+ echo "Trigger by change on $GITHUB_REPOSITORY. This is unexpected."
74+ ;;
75+ esac
76+ fi
77+
78+ echo ::set-output name=os_ref::$OS_REF
79+ echo ::set-output name=apps_ref::$APPS_REF
80+ echo ::set-output name=testing_ref::$TESTING_REF
81+
82+ - name : Checkout nuttx repo
83+ uses : actions/checkout@v2
84+ with :
85+ repository : apache/incubator-nuttx
86+ ref : ${{ steps.gittargets.outputs.os_ref }}
87+ path : sources/nuttx
88+ fetch-depth : 1
89+
90+ - name : Checkout apps repo
91+ uses : actions/checkout@v2
92+ with :
93+ repository : apache/incubator-nuttx-apps
94+ ref : ${{ steps.gittargets.outputs.apps_ref }}
95+ path : sources/apps
96+ fetch-depth : 1
97+
98+ - name : Checkout testing repo
99+ uses : actions/checkout@v2
100+ with :
101+ repository : apache/incubator-nuttx-testing
102+ ref : ${{ steps.gittargets.outputs.testing_ref }}
103+ path : sources/testing
104+ fetch-depth : 1
105+
106+ - name : Create Source Bundle
107+ run : tar -czf sources.tar.gz sources
108+ - name : Archive Source Bundle
109+ uses : actions/upload-artifact@v1
110+ with :
111+ name : source-bundle
112+ path : sources.tar.gz
113+
114+ - name : Cache Source
115+ id : cache-source
116+ uses : actions/cache@v1
117+ with :
118+ path : sources
119+ key : build-sources-${{ github.run_id }}
120+
19121 Linux :
20- runs-on : ubuntu-18.04
122+ needs : Fetch-Source
123+ runs-on : ubuntu-latest
21124 env :
22125 DOCKER_BUILDKIT : 1
23126
24127 strategy :
25128 matrix :
26129 boards : [arm-01, arm-02, arm-03, arm-04, arm-05, arm-06, arm-07, arm-08, arm-09, arm-10, arm-11, arm-12, arm-13, mips-riscv-x86-xtensa, sim]
130+
27131 steps :
28- - name : Checkout nuttx repo
29- uses : actions/checkout@v2
30- with :
31- repository : apache/incubator-nuttx
32- path : nuttx
33- fetch-depth : 0
34-
35- - name : Fetch nuttx tags
36- run : |
37- cd nuttx
38- git fetch --tags
39-
40- - name : Checkout apps repo
41- uses : actions/checkout@v2
42- with :
43- repository : apache/incubator-nuttx-apps
44- path : apps
45- fetch-depth : 0
46-
47- - name : Checkout testing repo
48- uses : actions/checkout@v2
49- with :
50- repository : apache/incubator-nuttx-testing
51- path : testing
52-
53- - name : Docker Login
54- uses : azure/docker-login@v1
55- with :
56- login-server : docker.pkg.github.com
57- username : ${GITHUB_ACTOR}
58- password : ${{ secrets.GITHUB_TOKEN }}
59-
60- - name : Docker Pull
61- uses : nick-invision/retry@v1
62- with :
63- timeout_minutes : 10
64- max_attempts : 3
65- retry_wait_seconds : 10
66- command : docker pull docker.pkg.github.com/apache/incubator-nuttx-testing/nuttx-ci-linux
67-
68- - name : Run builds
69- uses : ./testing/.github/actions/ci-container
70- env :
71- BLOBDIR : /tools/blobs
72- with :
73- run : |
74- cd testing
75- ./cibuild.sh -x -G testlist/${{matrix.boards}}.dat
132+ - name : Fetch Cached Source
133+ id : cache-source
134+ uses : actions/cache@v1
135+ with :
136+ path : sources-cache
137+ key : build-sources-${{ github.run_id }}
138+ - name : Prevent Updating Source Cache
139+ if : steps.cache-source.outputs.cache-hit == 'true'
140+ run : mv sources-cache sources
141+ - name : Download Source Artifact
142+ if : steps.cache-source.outputs.cache-hit != 'true'
143+ uses : actions/download-artifact@v1
144+ with :
145+ name : source-bundle
146+ path : ./
147+ - name : Extract Source Artifact
148+ if : steps.cache-source.outputs.cache-hit != 'true'
149+ run : tar -xf sources.tar.gz
150+
151+ - name : Docker Login
152+ uses : azure/docker-login@v1
153+ with :
154+ login-server : docker.pkg.github.com
155+ username : ${GITHUB_ACTOR}
156+ password : ${{ secrets.GITHUB_TOKEN }}
157+
158+ - name : Docker Pull
159+ uses : nick-invision/retry@v1
160+ with :
161+ timeout_minutes : 10
162+ max_attempts : 3
163+ retry_wait_seconds : 10
164+ command : docker pull docker.pkg.github.com/apache/incubator-nuttx-testing/nuttx-ci-linux
165+
166+ - name : Run builds
167+ uses : ./sources/testing/.github/actions/ci-container
168+ env :
169+ BLOBDIR : /tools/blobs
170+ with :
171+ run : |
172+ git -C sources/nuttx fetch --tags
173+ cd sources/testing
174+ ./cibuild.sh -x -G testlist/${{matrix.boards}}.dat
76175
77176 macOS :
78177 runs-on : macos-10.15
79-
178+ needs : Fetch-Source
80179 strategy :
81180 matrix :
82181 boards : [arm-12, mips-riscv-x86-xtensa, sim]
182+ steps :
183+ - name : Fetch Cached Source
184+ id : cache-source
185+ uses : actions/cache@v1
186+ with :
187+ path : sources-cache
188+ key : build-sources-${{ github.run_id }}
189+ - name : Prevent Updating Source Cache
190+ if : steps.cache-source.outputs.cache-hit == 'true'
191+ run : mv sources-cache sources
192+ - name : Download Source Artifact
193+ if : steps.cache-source.outputs.cache-hit != 'true'
194+ uses : actions/download-artifact@v1
195+ with :
196+ name : source-bundle
197+ path : ./
198+ - name : Extract Source Artifact
199+ if : steps.cache-source.outputs.cache-hit != 'true'
200+ run : tar -xf sources.tar.gz
201+
202+ - name : Restore Tools Cache
203+ id : cache-tools
204+ uses : actions/cache@v1
205+ env :
206+ cache-name : ${{ runner.os }}-cache-tools
207+ with :
208+ path : prebuilt
209+ key : ${{ runner.os }}-tools-${{ hashFiles('./sources/testing/cibuild.sh') }}
210+
211+ - name : Run Builds
212+ run : |
213+ git -C sources/nuttx fetch --tags
214+ cd sources/testing
215+ ./cibuild.sh -i -x -G testlist/${{matrix.boards}}.dat
83216
217+ Cygwin :
218+ runs-on : windows-latest
219+ needs : Fetch-Source
220+ strategy :
221+ matrix :
222+ boards : [sim-cygwin]
84223 steps :
85- - name : Checkout nuttx repo
86- uses : actions/checkout@v2
87- with :
88- repository : apache/incubator-nuttx
89- path : nuttx
90- fetch-depth : 0
91-
92- - name : Fetch nuttx tags
93- run : |
94- cd nuttx
95- git fetch --tags
96-
97- - name : Checkout apps repo
98- uses : actions/checkout@v2
99- with :
100- repository : apache/incubator-nuttx-apps
101- path : apps
102- fetch-depth : 0
103-
104- - name : Checkout testing repo
105- uses : actions/checkout@v2
106- with :
107- repository : apache/incubator-nuttx-testing
108- path : testing
109-
110- - name : Restore cache
111- id : cache-tools
112- uses : actions/cache@v1
113- env :
114- cache-name : ${{ runner.os }}-cache-tools
115- with :
116- path : prebuilt
117- key : ${{ runner.os }}-tools-${{ hashFiles('./testing/cibuild.sh') }}
118-
119- - name : Run builds
120- run : |
121- cd testing
122- ./cibuild.sh -i -x -G testlist/${{matrix.boards}}.dat
224+ - name : Fetch Cached Source
225+ id : cache-source
226+ uses : actions/cache@v1
227+ with :
228+ path : sources-cache
229+ key : build-sources-${{ github.run_id }}
230+ - name : Prevent Updating Source Cache
231+ if : steps.cache-source.outputs.cache-hit == 'true'
232+ run : mv sources-cache sources
233+ - name : Download Source Artifact
234+ if : steps.cache-source.outputs.cache-hit != 'true'
235+ uses : actions/download-artifact@v1
236+ with :
237+ name : source-bundle
238+ path : ./
239+ - name : Extract Source Artifact
240+ if : steps.cache-source.outputs.cache-hit != 'true'
241+ run : tar -xf sources.tar.gz
242+
243+ - name : Write Cygwin Package List # Needed for cache key hash
244+ shell : bash
245+ run : |
246+ echo -n "\
247+ make gcc-core gcc-g++ flex git bison byacc gperf gdb unzip awk automake-1.15 autoconf wget xxd
248+ libmpc-devel libncurses-devel libmpfr-devel zlib-devel" > cyg-requirements
249+
250+ # Cache is disabled here because cache breaks symlinks on Windows (https://github.com/actions/cache/issues/120)
251+ # - name: Cached Cygwin
252+ # id: cache-cygwin
253+ # uses: actions/cache@v1
254+ # with:
255+ # path: C:\tools\cygwin\
256+ # key: cygwin-3.1.4-${{ hashFiles('cyg-requirements') }}
257+ - name : Checkout tools repo
258+ run : |
259+ git config --global core.autocrlf false # We don't want CR to be added to the files
260+ git clone --depth 1 https://bitbucket.org/nuttx/tools.git sources/tools
261+ - name : Install cygwin base packages with chocolatey
262+ # if: steps.cache-cygwin.outputs.cache-hit != 'true'
263+ shell : pwsh
264+ run : |
265+ choco install --no-progress cygwin --version 3.1.4
266+ choco install cyg-get
267+ - name : Install NuutX Build Requirements for Cygwin
268+ # if: steps.cache-cygwin.outputs.cache-hit != 'true'
269+ shell : pwsh
270+ run : |
271+ cyg-get (Get-Content cyg-requirements)
272+ - name : Set ENV
273+ run : |
274+ echo '::set-env name=PATH::C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin'
275+
276+ - name : Build CI Tools
277+ shell : cmd
278+ run : |
279+ C:\tools\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -c "cd sources/testing && mkdir ../prebuilt && install=\"kconfig-frontends gen-romfs\" ./cibuild.sh -i"
280+ - name : Fetch Git Tags
281+ run : |
282+ git -C sources/nuttx fetch --tags
283+ - name : Reset git repos from Linux cache
284+ shell : cmd
285+ run : |
286+ C:\tools\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -c "cd sources/nuttx && git rm --cached -r . && git reset --hard"
287+ C:\tools\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -c "cd sources/apps && git rm --cached -r . && git reset --hard"
288+ - name : Run Builds
289+ shell : cmd
290+ run : |
291+ C:\tools\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -c "cd sources/testing && export PATH=$PATH:`pwd`/../prebuilt/kconfig-frontends/bin:`pwd`/../prebuilt/genromfs/usr/bin && ../nuttx/tools/testbuild.sh -c -x -G -j 2 -e \"-Wno-cpp -Werror\" testlist/${{matrix.boards}}.dat"
0 commit comments