Skip to content

Preliminary bzlmod support #240

Preliminary bzlmod support

Preliminary bzlmod support #240

Workflow file for this run

name: Continuous integration
on:
push:
branches: main
pull_request:
branches: main
workflow_dispatch: # allows manual triggering
env:
# Bump this number to invalidate the GH actions cache
cache-version: 0
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]
enable-bzlmod: false

Check failure on line 20 in .github/workflows/workflow.yaml

View workflow run for this annotation

GitHub Actions / Continuous integration

Invalid workflow file

The workflow is not valid. .github/workflows/workflow.yaml (Line: 20, Col: 24): Unexpected value 'false'
include:
- ghc-version: ghc_9_4_5
enable-bzlmod: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Mount Bazel cache
uses: actions/cache@v3
with:
path: ~/repo-cache
key: repo-cache-${{ runner.os }}-nixpkgs-${{ env.cache-version }}
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=./nixpkgs.nix
- name: Configure
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
if [ -z "$BUILDBUDDY_API_KEY" ]; then
cache_setting='--noremote_upload_local_results'
else
cache_setting="--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY"
fi
cat >.bazelrc.local <<EOF
build --host_platform=@rules_nixpkgs_core//platforms:host
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://cloud.buildbuddy.io
build --remote_cache=grpcs://cloud.buildbuddy.io
build $cache_setting
build --remote_timeout=600
build --keep_backend_build_event_connections_alive=false
build --repository_cache=~/repo-cache/
EOF
if [[ ${{ matrix.enable-bzlmod }} ]]
echo "common --config=bzlmod" >>.bazelrc.local
fi
ln -s ../.bazelrc.local example/.bazelrc.local
ln -s ../../.bazelrc.local tests/alternative-deps/.bazelrc.local
- name: Build & test
run: nix-shell --pure --run 'bazel test --config=${{ matrix.ghc-version }} --test_output=all //...'
if: ${{ !matrix.enable-bzlmod }}
- 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
run: |
cd tests/alternative-deps
nix-shell --pure --run 'bazel run //:gazelle --config=${{ matrix.ghc-version }}'
nix-shell --pure --run 'bazel run //:gazelle-update-repos --config=${{ matrix.ghc-version }}'
nix-shell --pure --run 'bazel test //... --config=${{ matrix.ghc-version }}'
if: ${{ !matrix.enable-bzlmod }}
- name: Test for buildifier suggestions
run: nix-shell --pure --run 'bazel run //:buildifier-diff'
if: ${{ !matrix.enable-bzlmod }}