Skip to content

Integration Tests #4762

Integration Tests

Integration Tests #4762

name: Integration Tests
# Only run workflow manually
# Refer to https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch
on:
push:
workflow_dispatch:
schedule:
- cron: "0 5 * * *" # At 05:00 on every day.
jobs:
integration-test:
name: integration-test
runs-on: "fossa-cli-integration-runner"
# Be sure to update the env below too
container: fossa/haskell-static-alpine:ghc-9.8.2
env:
GHC_VERSION: '9.8.2'
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 2
- name: Ensures git ownership check does not lead to compile error (we run git during compile for version tagging, etc.)
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
# adduser cannot add users to group: https://unix.stackexchange.com/a/397733
# so we edit /etc/group directly
- name: Create nixbuild users/group
run: |
addgroup nixbld
adduser -D nixbld-1
adduser -D nixbld-2
adduser -D nixbld-3
sed 's/nixbld:x:\([[:digit:]]*\):$/nixbld:x:\1:nixbld-1,nixbld-2,nixbld-3/' /etc/group > group-changed
mv group-changed /etc/group
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: "build-users-group = nixbld"
- name: Debugging information
run: |
ghc --version || echo "no ghc"
cabal --version || echo "no cabal"
ghcup --version || echo "no ghcup"
rustc -V || echo "no rustc"
cargo -V || echo "no cargo"
- uses: Swatinem/rust-cache@v2
# Compute cache key and save to a temporary file.
#
# We compute the cache key based on the solved install plan instead of just
# hashing the `.cabal` file, since there are many kinds of changes that will
# cause `.cabal` to change (e.g. adding new source modules).
- name: Compute cache key
id: compute-cache-key
run: |
cabal --project-file=cabal.project.ci.linux update
cabal --project-file=cabal.project.ci.linux build --dry-run
cat dist-newstyle/cache/plan.json | jq '."install-plan"[]."id"' | sort > /tmp/cabal-cache-key
echo "Install plan:"
cat /tmp/cabal-cache-key
export CABAL_CACHE_KEY=$(sha256sum /tmp/cabal-cache-key | awk '{print $1}')
echo "Cabal cache key: $CABAL_CACHE_KEY"
echo "cabal-cache-key=$CABAL_CACHE_KEY" >> $GITHUB_OUTPUT
echo "parent_commit=$(git rev-parse HEAD^)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Cache cabal store
with:
path: ${{ steps.setup-haskell.outputs.cabal-store || '~/.local/state/cabal' }}
key: ${{ runner.os }}-${{ env.GHC_VERSION }}-cabal-cache-${{ steps.compute-cache-key.outputs.cabal-cache-key }}
restore-keys: |
${{ runner.os }}-${{ env.GHC_VERSION }}-cabal-cache-
${{ runner.os }}-${{ env.GHC_VERSION }}-
${{ runner.os }}-
- uses: actions/cache@v4
name: Cache dist-newstyle
with:
path: ${{ github.workspace }}/dist-newstyle
key: ${{ runner.os }}-${{ env.GHC_VERSION }}-dist-newstyle-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.GHC_VERSION }}-dist-newstyle-${{ env.parent_commit }}
${{ runner.os }}-${{ env.GHC_VERSION }}-dist-newstyle-
${{ runner.os }}-${{ env.GHC_VERSION }}-
${{ runner.os }}-
- name: Build Rust dependencies
run: cargo build --release
- name: Update vendored binaries
run: |
mkdir vendor-bins
./vendor_download.sh
env:
GITHUB_TOKEN: ${{ secrets.BASIS_ACCESS_TOKEN }}
- name: Build
env:
RUN_CMD: cabal build --project-file=cabal.project.ci.linux all
run: |
cabal update
$RUN_CMD || $RUN_CMD
# This is set up to run integration tests in parallel.
# If that becomes a problem disable it by removing the "+RTS -N -RTS" test options.
- name: Run all integration tests
run: |
cabal test --project-file=cabal.project.ci.linux --test-show-details=direct --test-option=--times integration-tests --test-options="+RTS -N -RTS"