Skip to content

ci(mergify): upgrade configuration to current format #841

ci(mergify): upgrade configuration to current format

ci(mergify): upgrade configuration to current format #841

Workflow file for this run

name: Continuous integration
on:
push:
branches: main
pull_request:
branches: main
workflow_dispatch: # allows manual triggering
schedule:
- cron: '1 11 * * *'
env:
# Bump this number to invalidate the GH actions cache
cache-version: 0
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
test-nixpkgs:
name: Build & Test - Nixpkgs
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc-version: [ghc_8_10_7, ghc_9_0_2, ghc_9_2_7, ghc_9_4_5, ghc_9_6_5]
enable-bzlmod: [false]
include:
- os: ubuntu-latest
ghc-version: ghc_9_2_7
enable-bzlmod: true
- os: ubuntu-latest
ghc-version: ghc_9_4_5
enable-bzlmod: true
- os: ubuntu-latest
ghc-version: ghc_9_6_5
enable-bzlmod: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Mount Bazel cache
uses: actions/cache@v4
with:
path: ~/repo-cache
key: repo-cache-${{ runner.os }}-nixpkgs-${{ env.cache-version }}
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=./nixpkgs.nix
- uses: tweag/configure-bazel-remote-cache-auth@v0
with:
buildbuddy_api_key: ${{ secrets.BUILDBUDDY_API_KEY }}
bazelrc_path: .bazelrc.auth
- name: Configure
run: |
# Convert "ghc_X_Y_Z" to "X.Y.Z".
GHC_VERSION="$(sed 's/^ghc_//;s/_/./g' <<<"${{ matrix.ghc-version }}")"
bzlmod_setting=
if [[ ${{ matrix.enable-bzlmod }} = true ]]; then
bzlmod_setting="common --config=bzlmod"
# Update the GHC_VERSION in MODULE.bazel
sed -i.bak 's/^GHC_VERSION = .*$/GHC_VERSION = "'"$GHC_VERSION"'"/g' example/MODULE.bazel
fi
cat >>.bazelrc.local <<EOF
build --host_platform=@rules_nixpkgs_core//platforms:host
build --config=remote-cache
build --repository_cache=~/repo-cache/
$bzlmod_setting
EOF
ln -s ../.bazelrc.local example/.bazelrc.local
ln -s ../../.bazelrc.local tests/alternative-deps/.bazelrc.local
- name: Build & test
if: ${{ !matrix.enable-bzlmod }}
uses: tweag/run-nix-shell@v0
with:
run: bazel test --config=${{ matrix.ghc-version }} --test_output=all //...
- name: Test the example
run: |
cd example
nix-shell --pure --run 'bazel run //:gazelle --config=${{ matrix.ghc-version }}'
# Gazelle doesn't remove rules by default
grep -q another-haskell-binary package-a/BUILD.bazel
nix-shell --pure --run 'bazel run //:gazelle --config=${{ matrix.ghc-version }} -- fix -mode diff' || true
nix-shell --pure --run 'bazel run //:gazelle --config=${{ matrix.ghc-version }} -- fix'
# Test that fix kept and removed the expected rules
echo "! grep -q another-haskell-binary package-a/BUILD.bazel"
bash -c "! grep -q another-haskell-binary package-a/BUILD.bazel"
echo grep -q a-haskell-binary package-a/BUILD.bazel
grep -q a-haskell-binary package-a/BUILD.bazel
echo grep -q haskell_toolchain_library package-a/BUILD.bazel
grep -q haskell_toolchain_library package-a/BUILD.bazel
# Test main_file attribute (taken from cabal's main_is)
# Simple scenario: main-is: Main.hs & hs-source-dirs: app
bash -cx 'grep -q "main_file = \"app/Main.hs\"" package-a/BUILD.bazel'
# Check concatenation when main-is: prank/Main.B and hs-source-dirs: app
bash -cx 'grep -q "main_file = \"app/prank/MainB.hs\"" package-a/BUILD.bazel'
# Test sublibrary generation
bash -cx "grep -q \"sublibPub\" package-b/BUILD.bazel"
bash -cx "grep -q \"mtl\" package-b/BUILD.bazel"
# Test sublibrary shadowing
bash -cx "grep -q \":sublibPub\" package-b/BUILD.bazel"
bash -cx "grep -q \":mtl\" package-b/BUILD.bazel"
# Test public internal library feature
bash -cx "grep -q \"//package-b:sublibPub\" package-a/BUILD.bazel"
# Test dependency on local libraries (the same name)
bash -cx "grep -q \":sublibPub\" package-a/BUILD.bazel"
bash -cx "grep -q \":sublibPriv\" package-a/BUILD.bazel"
# Test dependency on local libraries (the same name)
# with experimental colon syntax
bash -cx "grep -q \":colonPub\" package-a/BUILD.bazel"
bash -cx "grep -q \":colonPriv\" package-a/BUILD.bazel"
# Test existence of package-b main lib dependency
# referenced with colon syntax: package-b:package-b
bash -cx "grep -q \"//package-b\" package-a/BUILD.bazel"
# Test existence of package-c main library
# referenced without colon syntax: package-c
bash -cx "grep -q \"//package-c\" package-a/BUILD.bazel"
# Test that unknown libraries referenced with colon syntax
# are resolved from repository
bash -cx "grep -q \"@stackage//:tasty\" package-a/BUILD.bazel"
# Test sublibrary local dependency resolution
# mtl must be taken from repo not from package-b
bash -cx "grep -q \"@stackage//:mtl\" package-a/BUILD.bazel"
bash -cx "! grep -q \"//package-b:mtl\" package-a/BUILD.bazel"
# Test that colon syntax allows to reference both
# local and other package dependency
bash -cx "grep -q \":mtl\" package-b/BUILD.bazel"
bash -cx "grep -q \"//package-c:mtl\" package-b/BUILD.bazel"
# Test gazelle-update-repos
nix-shell --pure --run 'bazel run //:gazelle-update-repos --config=${{ matrix.ghc-version }}'
nix-shell --pure --run 'bazel test //... --config=${{ matrix.ghc-version }}'
- name: Test alternative dependencies
if: ${{ !matrix.enable-bzlmod }}
uses: tweag/run-nix-shell@v0
with:
working-directory: tests/alternative-deps
run: |
bazel run //:gazelle --config=${{ matrix.ghc-version }}
bazel run //:gazelle-update-repos --config=${{ matrix.ghc-version }}
bazel test //... --config=${{ matrix.ghc-version }}
- name: Test for buildifier suggestions
if: ${{ !matrix.enable-bzlmod }}
uses: tweag/run-nix-shell@v0
with:
run: bazel run //:buildifier-diff
all_ci_tests:
runs-on: ubuntu-latest
needs:
- test-nixpkgs
if: ${{ always() }}
steps:
- uses: cgrindel/gha_join_jobs@794a2d117251f22607f1aab937d3fd3eaaf9a2f5 # v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}