-
Notifications
You must be signed in to change notification settings - Fork 5
117 lines (115 loc) · 5.74 KB
/
workflow.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Mount Bazel cache
uses: actions/cache@v2
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=@io_tweag_rules_nixpkgs//nixpkgs/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
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 //...'
- 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 }}'
- name: Test for buildifier suggestions
run: nix-shell --pure --run 'bazel run //:buildifier-diff'