11name : CI
22
3- on :
3+ on :
44 push :
55 pull_request :
66 release :
1616 RUST_BACKTRACE : " full" # Make Rust print full backtrace on error
1717
1818jobs :
19- Build :
19+ stack-build :
2020 runs-on : ${{ matrix.os }}
2121 strategy :
2222 fail-fast : false
88888989 with :
9090 format : ' YYYY-MM'
91-
91+
9292 - name : Setup github actions cache
9393 id : cache
9494 uses : actions/cache@v2
9898
9999 - name : Build Haskell fpm
100100 run : |
101- cd bootstrap
102101 stack build
103102 stack install
103+ working-directory : bootstrap
104104
105105 - name : put fpm to PATH (macOS)
106106 if : contains(matrix.os, 'macos')
@@ -116,34 +116,200 @@ jobs:
116116 if : contains(matrix.os, 'ubuntu')
117117 run : |
118118 sudo cp /home/runner/.local/bin/fpm /usr/local/bin
119-
119+
120120 - name : Run tests on Haskell fpm
121121 run : |
122- cd bootstrap
123122 stack test
124-
125- - name : Build and test Fortran fpm
126- run : ${{ matrix.TEST_SCRIPT }}
127-
128- - name : Build and test Fortran fpm (release version)
129- run : ${{ matrix.TEST_SCRIPT }} ${{ matrix.RELEASE_FLAGS }}
123+ working-directory : bootstrap
130124
131125 # ----- Upload binaries if creating a release -----
132126 - name : Check that fpm --version matches release tag
133127 if : github.event_name == 'release'
134128 run : |
135- cd fpm
136129 ${{ matrix.GET_VERSION_CMD }} > fpm_version
137- fpm run -- "--version" | ${{ matrix.CHECK_VERSION_CMD }}
130+ working-directory : fpm
138131
139132 - name : Stage release files for upload
140133 if : github.event_name == 'release'
141134 run : |
142- cd fpm
143- fpm run ${{ matrix.RELEASE_FLAGS }} --runner ${{ matrix.RELEASE_CMD }}
144135 ${{ matrix.BOOTSTRAP_RELEASE_CMD }}
145136 ${{ matrix.HASH_CMD }}
146-
137+ working-directory : fpm
138+
139+ - name : Upload assets
140+ if : github.event_name == 'release'
141+ uses : svenstaro/upload-release-action@v2
142+ with :
143+ repo_token : ${{ secrets.GITHUB_TOKEN }}
144+ file : fpm/fpm-*
145+ file_glob : true
146+ tag : ${{ github.ref }}
147+ overwrite : true
148+
149+ build :
150+ runs-on : ${{ matrix.os }}
151+ strategy :
152+ fail-fast : false
153+ matrix :
154+ os : [ubuntu-latest, macos-latest, windows-latest]
155+ gcc_v : [9] # Version of GFortran we want to use.
156+ include :
157+ - os : ubuntu-latest
158+ os-arch : linux-x86_64
159+ release-flags : --flag '--static -g -fbacktrace -O3'
160+ sha256sum : sha256sum
161+
162+ - os : macos-latest
163+ os-arch : macos-x86_64
164+ release-flags : --flag '-g -fbacktrace -O3'
165+ sha256sum : shasum -a 256
166+
167+ - os : windows-latest
168+ os-arch : windows-x86_64
169+ release-flags : --flag '--static -g -fbacktrace -O3'
170+ exe : .exe
171+ sha256sum : sha256sum
172+
173+ env :
174+ FC : gfortran
175+ GCC_V : ${{ matrix.gcc_v }}
176+
177+ steps :
178+ - name : Checkout code
179+ uses : actions/checkout@v1
180+
181+ - name : Install GFortran macOS
182+ if : contains(matrix.os, 'macos')
183+ run : |
184+ ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
185+ which gfortran-${GCC_V}
186+ which gfortran
187+
188+ - name : Install GFortran Linux
189+ if : contains(matrix.os, 'ubuntu')
190+ run : |
191+ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
192+ --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
193+ --slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
194+
195+ # Phase 1: Bootstrap fpm with existing version
196+ - name : Install fpm
197+ uses : fortran-lang/setup-fpm@v3
198+ with :
199+ fpm-version : ' v0.2.0'
200+
201+ - name : Remove fpm from path
202+ shell : bash
203+ run : |
204+ mv $(which fpm) fpm-bootstrap${{ matrix.exe }}
205+ echo "BOOTSTRAP=$PWD/fpm-bootstrap" | cat >> $GITHUB_ENV
206+
207+ - name : Build Fortran fpm (bootstrap)
208+ shell : bash
209+ run : |
210+ ${{ env.BOOTSTRAP }} build
211+ working-directory : fpm
212+
213+ - name : Run Fortran fpm (bootstrap)
214+ shell : bash
215+ run : |
216+ ${{ env.BOOTSTRAP }} run
217+ ${{ env.BOOTSTRAP }} run -- --version
218+ ${{ env.BOOTSTRAP }} run -- --help
219+ working-directory : fpm
220+
221+ - name : Test Fortran fpm (bootstrap)
222+ shell : bash
223+ run : |
224+ ${{ env.BOOTSTRAP }} test
225+ working-directory : fpm
226+
227+ - name : Install Fortran fpm (bootstrap)
228+ shell : bash
229+ run : |
230+ ${{ env.BOOTSTRAP }} install
231+ working-directory : fpm
232+
233+ # Phase 2: Bootstrap fpm with itself
234+ - name : Replace bootstrapping version
235+ shell : bash
236+ run : |
237+ ${{ env.BOOTSTRAP }} run --runner cp -- fpm-debug${{ matrix.exe }}
238+ rm -v ${{ env.BOOTSTRAP }}
239+ echo "FPM=$PWD/fpm-debug" | cat >> $GITHUB_ENV
240+ working-directory : fpm
241+
242+ - name : Get version (normal)
243+ if : github.event_name != 'release'
244+ shell : bash
245+ run : |
246+ VERSION=$(git rev-parse --short HEAD)
247+ echo "VERSION=$VERSION" | cat >> $GITHUB_ENV
248+
249+ - name : Get version (release)
250+ if : github.event_name == 'release'
251+ shell : bash
252+ run : |
253+ VERSION=$(echo ${{ github.ref }} | cut -dv -f2)
254+ echo "VERSION=$VERSION" | cat >> $GITHUB_ENV
255+ FPM_VERSION=$(${{ env.FPM }} --version | grep -o '${{ env.REGEX }}')
256+ [ "$VERSION" = "$FPM_VERSION" ]
257+ env :
258+ REGEX : ' [0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}'
259+
260+ - name : Build example packages
261+ shell : bash
262+ run : |
263+ ci/run_tests.sh "${{ env.FPM }}"
264+
265+ - name : Build Fortran fpm
266+ shell : bash
267+ run : |
268+ ${{ env.FPM }} build ${{ matrix.release-flags }}
269+ working-directory : fpm
270+
271+ - name : Run Fortran fpm
272+ shell : bash
273+ run : |
274+ ${{ env.FPM }} run ${{ matrix.release-flags }}
275+ ${{ env.FPM }} run ${{ matrix.release-flags }} -- --version
276+ ${{ env.FPM }} run ${{ matrix.release-flags }} -- --help
277+ working-directory : fpm
278+
279+ - name : Test Fortran fpm
280+ shell : bash
281+ run : |
282+ ${{ env.FPM }} test ${{ matrix.release-flags }}
283+ working-directory : fpm
284+
285+ - name : Install Fortran fpm
286+ shell : bash
287+ run : |
288+ ${{ env.FPM }} install ${{ matrix.release-flags }}
289+ working-directory : fpm
290+
291+ - name : Package release version
292+ shell : bash
293+ run : |
294+ ${{ env.FPM }} run ${{ matrix.release-flags }} --runner cp -- ${{ env.EXE }}
295+ rm -v ${{ env.FPM }}
296+ echo "FPM_RELEASE=$PWD/${{ env.EXE }}" | cat >> $GITHUB_ENV
297+ working-directory : fpm
298+ env :
299+ EXE : fpm-${{ env.VERSION }}-${{ matrix.os-arch }}${{ matrix.exe }}
300+
301+ - name : Run release version
302+ shell : bash
303+ run : |
304+ ci/run_tests.sh "${{ env.FPM_RELEASE }}"
305+
306+ - name : Stage release files for upload
307+ if : github.event_name == 'release'
308+ shell : bash
309+ run : |
310+ ${{ matrix.sha256sum }} ${{ env.FPM_RELEASE }} > ${{ env.FPM_RELEASE }}.sha256
311+ working-directory : fpm
312+
147313 - name : Upload assets
148314 if : github.event_name == 'release'
149315 uses : svenstaro/upload-release-action@v2
0 commit comments