2020-11-12 19:21:44 +03:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
2022-02-08 17:34:32 +03:00
|
|
|
push: { branches: [main] }
|
2022-02-28 22:04:45 +03:00
|
|
|
pull_request: { }
|
2020-11-12 19:21:44 +03:00
|
|
|
create: { tags: [v*] }
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
working-directory: waspc
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cancel:
|
|
|
|
name: Cancel redundant actions already in progress
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Cancel actions in progress of same workflow and same branch
|
2021-04-23 20:15:18 +03:00
|
|
|
uses: styfle/cancel-workflow-action@0.9.0
|
2020-11-12 19:21:44 +03:00
|
|
|
with:
|
|
|
|
access_token: ${{ github.token }}
|
|
|
|
|
2021-04-24 23:16:27 +03:00
|
|
|
# Check that Haskell code is formatted.
|
|
|
|
code-formatter:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: mrkkrp/ormolu-action@v2
|
|
|
|
|
2020-11-12 19:21:44 +03:00
|
|
|
build:
|
|
|
|
name: Build Wasp
|
|
|
|
runs-on: ${{ matrix.os }}
|
2021-04-24 23:16:27 +03:00
|
|
|
needs: code-formatter
|
2020-11-12 19:21:44 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- ubuntu-latest
|
|
|
|
- macos-latest
|
|
|
|
- windows-latest
|
|
|
|
|
|
|
|
steps:
|
2021-04-23 20:15:18 +03:00
|
|
|
- name: Checkout the repo
|
2020-11-12 19:21:44 +03:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2021-04-23 20:15:18 +03:00
|
|
|
- name: Cache (Unix)
|
2020-11-12 19:21:44 +03:00
|
|
|
uses: actions/cache@v2
|
2021-04-24 11:36:13 +03:00
|
|
|
if: runner.os == 'Linux' || runner.os == 'macOS'
|
2020-11-12 19:21:44 +03:00
|
|
|
with:
|
|
|
|
path: |
|
2021-04-25 10:49:29 +03:00
|
|
|
# TODO: To reduce the cache size significantly, we might want to look into ensuring that
|
|
|
|
# GHC is not cached, since it is big and can be installed in couple of minutes.
|
|
|
|
# To do that, we will probably want to cache only ~/.stack/snapshots.
|
2020-11-14 14:44:52 +03:00
|
|
|
~/.stack
|
|
|
|
# TODO: Right now, actions/cache updates cache only if cache was not fetched.
|
|
|
|
# This is not ideal for us, because we would ideally update cache even if it
|
|
|
|
# was fetched, because we want to cache any newly installed packages.
|
|
|
|
# This was working normally on Travis and Appveyor.
|
|
|
|
# There is an issue for this, and for now we are using proposed "fix" from it,
|
|
|
|
# https://github.com/actions/cache/issues/342#issuecomment-673371329,
|
|
|
|
# which mitigates the problem by creating new cache for each job and then using
|
|
|
|
# the feature of restore-keys which makes sure that next cache picked is the
|
|
|
|
# latest one. However, this keeps creating new cache each time which is not
|
|
|
|
# ideal because caches keep getting evicted, so for example if Win job
|
|
|
|
# fails multiple times while others don't, its cache will likely get evicted,
|
|
|
|
# making it even slower to test and fix (uffff).
|
|
|
|
# When they fix this, we should remove ${{ github.run_id }} from the end of the key
|
|
|
|
# and also remove restore-keys.
|
2021-11-11 19:21:46 +03:00
|
|
|
key: wasp-build-{{ runner.os }}-${{ hashFiles('waspc/stack.yaml') }}-${{ github.run_id }}
|
2020-11-14 14:44:52 +03:00
|
|
|
restore-keys: |
|
2021-11-11 19:21:46 +03:00
|
|
|
wasp-build-{{ runner.os }}-${{ hashFiles('waspc/stack.yaml') }}-
|
2020-11-14 14:44:52 +03:00
|
|
|
|
2021-04-23 20:15:18 +03:00
|
|
|
- name: Cache (Windows)
|
|
|
|
uses: actions/cache@v2
|
2021-04-24 11:36:13 +03:00
|
|
|
if: runner.os == 'Windows'
|
2021-04-23 20:15:18 +03:00
|
|
|
with:
|
2021-04-25 10:49:29 +03:00
|
|
|
# C\:sr is where stack installs compiled dependencies.
|
|
|
|
# Caching this path reduces build time by 20 minutes while occupying only ~50mbs of cache space.
|
|
|
|
# To shave off 3 more minutes, we could add C:\Users\runneradmin\AppData\Local\Programs\stack
|
|
|
|
# to the cache -> this is where stack installs GHC. However, this adds ~900mb to the cache size!
|
2021-04-23 20:15:18 +03:00
|
|
|
path: |
|
2021-04-24 11:36:13 +03:00
|
|
|
C:\sr
|
2021-04-23 20:15:18 +03:00
|
|
|
# TODO: Check TODO in caching for Unix above.
|
2021-11-11 19:21:46 +03:00
|
|
|
key: wasp-build-{{ runner.os }}-${{ hashFiles('waspc/stack.yaml') }}-${{ github.run_id }}
|
2021-04-23 20:15:18 +03:00
|
|
|
restore-keys: |
|
2021-11-11 19:21:46 +03:00
|
|
|
wasp-build-{{ runner.os }}-${{ hashFiles('waspc/stack.yaml') }}-
|
2021-04-23 20:15:18 +03:00
|
|
|
|
2020-11-14 14:44:52 +03:00
|
|
|
# TODO: Remove this step once https://github.com/actions/cache/issues/445 is resolved.
|
|
|
|
- name: Fix MacOS problem with corrupt cached executable
|
|
|
|
if: runner.os == 'macOS'
|
2021-04-23 20:15:18 +03:00
|
|
|
run: rm -rf ~/.stack/setup-exe-cache
|
2020-11-12 19:21:44 +03:00
|
|
|
|
2021-04-23 20:15:18 +03:00
|
|
|
- name: Set up Haskell (Stack)
|
|
|
|
uses: haskell/actions/setup@v1
|
2020-11-12 19:21:44 +03:00
|
|
|
with:
|
|
|
|
ghc-version: latest
|
|
|
|
enable-stack: true
|
|
|
|
stack-version: latest
|
|
|
|
|
2021-04-23 20:15:18 +03:00
|
|
|
- name: Verify Haskell setup
|
2020-11-12 19:21:44 +03:00
|
|
|
run: |
|
|
|
|
stack --numeric-version
|
2021-04-23 20:15:18 +03:00
|
|
|
stack path --stack-root
|
2020-11-12 19:21:44 +03:00
|
|
|
ghc --version
|
|
|
|
|
|
|
|
- name: Build dependencies
|
|
|
|
run: stack --install-ghc test --only-dependencies
|
|
|
|
|
|
|
|
- name: Build Wasp & Run tests
|
|
|
|
run: stack test
|
|
|
|
|
2021-04-23 20:15:18 +03:00
|
|
|
- name: Create binary package (Unix)
|
2021-04-24 11:36:13 +03:00
|
|
|
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
|
2021-04-23 20:15:18 +03:00
|
|
|
run: |
|
2021-04-24 11:36:13 +03:00
|
|
|
OS_NAME=`case "${{ runner.os }}" in Linux) echo "linux";; macOS) echo "macos";; *) exit 1;; esac`
|
|
|
|
mkdir artifacts
|
|
|
|
./tools/make_binary_package.sh "artifacts/wasp-$OS_NAME-x86_64.tar.gz"
|
2021-04-23 20:15:18 +03:00
|
|
|
|
|
|
|
- name: Create Github release
|
|
|
|
uses: ncipollo/release-action@v1
|
2021-04-24 11:36:13 +03:00
|
|
|
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
|
2021-04-23 20:15:18 +03:00
|
|
|
with:
|
|
|
|
draft: true
|
|
|
|
allowUpdates: true
|
2021-04-24 11:36:13 +03:00
|
|
|
artifacts: "waspc/artifacts/*"
|
2021-04-23 20:15:18 +03:00
|
|
|
artifactErrorsFailBuild: true
|
2021-04-24 11:36:13 +03:00
|
|
|
replacesArtifacts: true
|
2021-04-23 20:15:18 +03:00
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|