mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-18 14:41:41 +03:00
122 lines
4.4 KiB
YAML
122 lines
4.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push: { branches: [main] }
|
|
pull_request: { }
|
|
create: { tags: [v*] }
|
|
schedule:
|
|
# Additionally run once per week (At 00:00 on Sunday) to avoid loosing cache
|
|
# (GH deletes it after 7 days of not using it).
|
|
- cron: '0 0 * * 0'
|
|
|
|
env:
|
|
WASP_TELEMETRY_DISABLE: 1
|
|
|
|
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
|
|
uses: styfle/cancel-workflow-action@0.9.0
|
|
with:
|
|
access_token: ${{ github.token }}
|
|
|
|
build:
|
|
name: Build Wasp
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
ghc:
|
|
- "8.10.7"
|
|
cabal:
|
|
- "3.6.2.0"
|
|
os:
|
|
- ubuntu-latest
|
|
- macos-latest
|
|
- windows-latest
|
|
|
|
steps:
|
|
- name: Checkout the repo
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up Haskell
|
|
id: setup-haskell-cabal
|
|
uses: haskell/actions/setup@v1
|
|
with:
|
|
ghc-version: ${{ matrix.ghc }}
|
|
cabal-version: ${{ matrix.cabal }}
|
|
|
|
- name: Verify Haskell setup
|
|
run: |
|
|
ghc --version
|
|
cabal --version
|
|
|
|
- name: Cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
|
|
# 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.
|
|
key: wasp-build-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('waspc/cabal.project.freeze') }}-${{ github.run_id }}
|
|
restore-keys: wasp-build-${{ runner.os }}-${{ matrix.ghc }}-
|
|
|
|
- name: Check Haskell code formatting
|
|
if: matrix.os == 'ubuntu-latest'
|
|
run: ./run ormolu:check
|
|
|
|
- name: Check if cabal freeze file is up to date
|
|
if: matrix.os == 'ubuntu-latest'
|
|
run: |
|
|
# We do the check by running `cabal freeze` and checking if cabal.project.freeze
|
|
# changed. If it didn't, it is up to date, otherwise it is not.
|
|
# If there is no cabal.project.freeze, or `cabal freeze` command failed, that is also red flag.
|
|
[[ -f cabal.project.freeze ]] || exit 1
|
|
OLD_FREEZE_SUM=$(md5sum cabal.project.freeze)
|
|
cabal freeze || exit 1
|
|
NEW_FREEZE_SUM=$(md5sum cabal.project.freeze)
|
|
[[ "$NEW_FREEZE_SUM" == "$OLD_FREEZE_SUM" ]]
|
|
|
|
- name: Build external dependencies
|
|
run: cabal build --enable-tests --enable-benchmarks --only-dependencies
|
|
|
|
- name: Build wasp code
|
|
run: cabal build all
|
|
|
|
- name: Run tests
|
|
run: cabal test
|
|
|
|
- name: Create binary package (Unix)
|
|
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
|
|
run: |
|
|
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"
|
|
|
|
- name: Create Github release
|
|
uses: ncipollo/release-action@v1
|
|
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
|
|
with:
|
|
draft: true
|
|
allowUpdates: true
|
|
artifacts: "waspc/artifacts/*"
|
|
artifactErrorsFailBuild: true
|
|
replacesArtifacts: true
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|