Skip to content

Commit

Permalink
GitLab CI: Simplify finding binaries (#2669)
Browse files Browse the repository at this point in the history
The `build` job creates an artifact that subsequent jobs download to run
the tests. The jobs that actually run the tests cannot use
`cabal list-bin` because the artifact doesn't include enough of the
build data. We can simplify finding the binaries by having the artifact
include symlinks to the binaries, created in the `build` job where
`cabal list-bin` still works.

The artifact included some bits that seem redundant since PR #2403, they
have been removed.

GHC versions in CI are updated to the latest point release, and include
GHC 9.10.1 in preparation for PR #2790.

Fixed a mistake in the Docker image: use the same Ubuntu version for
building and for running.

In GitLab CI, the `after_script` cannot use environment variables set in
`before_script` or `script`. We use `zstd -T$THREADS` in `after_script`.
Before this commit, that rendered to `zstd -T` which happens to mean
"use all cores" and worked fine but was unintended.

Triggered child pipelines (`.ci/gitlab/test.yml`) did not have
`interruptible: true` set. Moved the `default` section into
`.ci/gitlab/common.yml`.

Some GitHub actions were upgraded because the old ones were deprecated.
This unearthed an error with macOS, so a workaround is applied. Note
that it would seem we've been running an x86-64 GHC on an aarch64 runner
with Stack 2.11.1 for quite some time already, and continue doing so.

(cherry picked from commit b96bf07)
  • Loading branch information
DigitalBrains1 committed Nov 5, 2024
1 parent 435c4a9 commit 851f35f
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 57 deletions.
16 changes: 16 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ set -u
# Build with default constraints
cabal v2-build all --write-ghc-environment-files=always

# Put all the test binaries in a predictable location
TESTS="
clash-cores:unittests
clash-cosim:test
clash-ffi:ffi-interface-tests
clash-lib:doctests
clash-lib:unittests
clash-prelude:doctests
clash-prelude:unittests
clash-testsuite:clash-testsuite
"
mkdir bin
for TEST in $TESTS; do
ln -s "$(realpath --relative-to=bin "$(cabal list-bin $TEST)")" bin/$TEST
done

# `CI_COMMIT_TAG` is set when a tag has been created on GitHub. We use this to
# trigger a release pipeline (release to Snap / Hackage).
if [[ ${CI_COMMIT_TAG:-} != "" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions .ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# To use buildkit, you need to set DOCKER_BUILDKIT=1 in your shell

ARG UBUNTU_VERSION=jammy-20230308
ARG UBUNTU_VERSION
FROM ubuntu:$UBUNTU_VERSION AS builder

LABEL vendor="QBayLogic B.V." maintainer="[email protected]"
Expand Down Expand Up @@ -122,7 +122,7 @@ RUN curl "https://downloads.haskell.org/~ghcup/$ghcup_version/x86_64-linux-ghcup
&& ghcup install ghc $ghc_version --set \
&& ghcup install cabal $cabal_version --set

ARG UBUNTU_VERSION=focal-20210416
ARG UBUNTU_VERSION
FROM ubuntu:$UBUNTU_VERSION AS run

LABEL vendor="QBayLogic B.V." maintainer="[email protected]"
Expand Down
4 changes: 3 additions & 1 deletion .ci/docker/build-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ elif [[ "$1" != "" ]]; then
exit 1
fi

GHC_VERSIONS=( "9.8.2" "9.6.4" "9.4.6" "9.2.8" "9.0.2" "8.10.7" "8.8.4" "8.6.5")
UBUNTU_VERSION=jammy-20240911.1
GHC_VERSIONS=("9.10.1" "9.8.2" "9.6.6" "9.4.8" "9.2.8" "9.0.2" "8.10.7" "8.8.4" "8.6.5")
CABAL_VERSION="3.12.1.0"

# We want to use docker buildkit so that our layers are built in parallel. This
Expand All @@ -26,6 +27,7 @@ do
GHC_VERSION="${GHC_VERSIONS[i]}"

docker build \
--build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \
--build-arg cabal_version=${CABAL_VERSION} \
--build-arg ghc_version=${GHC_VERSION} \
-t "${REPO}/${NAME}:${GHC_VERSION}-$now" \
Expand Down
13 changes: 0 additions & 13 deletions .ci/find_cabal_bin.sh

This file was deleted.

10 changes: 5 additions & 5 deletions .ci/get_build_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ done
echo "${GIT_ROOT}"/dist-newstyle
ls "${GIT_ROOT}"/.ghc.environment.*

# Pack source distribution too to prevent rebuilds due to changed modification
# dates.
ls -d "${GIT_ROOT}"/clash-*
# Some build products for clash-cosim are here
echo "${GIT_ROOT}"/clash-cosim/src/cbits
echo "${GIT_ROOT}"/clash-cosim/src/prims

# Include compile options
echo "${GIT_ROOT}"/cabal.project.local
# Include symlinks to built binaries
echo "${GIT_ROOT}"/bin
2 changes: 1 addition & 1 deletion .ci/gitlab/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.benchmark:
image: ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20240726
image: ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20241008
stage: test
timeout: 2 hours
variables:
Expand Down
14 changes: 12 additions & 2 deletions .ci/gitlab/common.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
default:
# Make all tasks interruptible by default
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure

.common:
image: ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20240726
image: ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20241008
timeout: 10 minutes
stage: build
variables:
# Note that we copy+paste the image name into CACHE_FALLBACK_KEY. If we don't,
# $GHC_VERSION gets inserted at verbatim, instead of resolving to some ghc version.
CACHE_FALLBACK_KEY: $CI_JOB_NAME-master-ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20240726-3-3-non_protected
CACHE_FALLBACK_KEY: $CI_JOB_NAME-master-ghcr.io/clash-lang/clash-ci:$GHC_VERSION-20241008-3-3-non_protected
GIT_SUBMODULE_STRATEGY: recursive
TERM: xterm-color
cache:
Expand All @@ -21,6 +30,7 @@
- tar -xf cache.tar.zst -C / || true
- .ci/setup.sh
after_script:
- export THREADS=$(./.ci/effective_cpus.sh)
- tar -cf - $(ls -d /root/.cabal /root/.stack || true) | zstd -T${THREADS} -3 > cache.tar.zst

# We run tests on local machines if:
Expand Down
27 changes: 14 additions & 13 deletions .ci/gitlab/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,37 +94,37 @@ build:
cores:unittests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-cores unittests t) --hide-successes
- bin/clash-cores:unittests --hide-successes

cosim:unittests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-cosim test t)
- bin/clash-cosim:test

prelude:unittests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-prelude unittests t) --hide-successes
- bin/clash-prelude:unittests --hide-successes

lib:doctests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-lib doctests t) -j${THREADS}
- bin/clash-lib:doctests -j$THREADS

lib:unittests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-lib unittests t) --hide-successes
- bin/clash-lib:unittests --hide-successes

prelude:doctests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-prelude doctests t) -j${THREADS}
- bin/clash-prelude:doctests -j$THREADS

ffi:interface-tests:
extends: .test-nocache
script:
- $(.ci/find_cabal_bin.sh clash-ffi ffi-interface-tests x) --smallcheck-max-count 2000
- bin/clash-ffi:ffi-interface-tests --smallcheck-max-count 2000

# Tests run on local fast machines:

Expand All @@ -140,25 +140,25 @@ build-clash-dev:
suite:vhdl:
extends: .test-cache-local
script:
- $(.ci/find_cabal_bin.sh clash-testsuite clash-testsuite x) -j${THREADS} -p .VHDL --hide-successes --no-vivado
- bin/clash-testsuite:clash-testsuite -j$THREADS -p .VHDL --hide-successes --no-vivado

suite:verilog:
extends: .test-cache-local
script:
- $(.ci/find_cabal_bin.sh clash-testsuite clash-testsuite x) -j${THREADS} -p .Verilog --hide-successes --no-vivado
- bin/clash-testsuite:clash-testsuite -j$THREADS -p .Verilog --hide-successes --no-vivado

suite:systemverilog:
extends: .test-cache-local
script:
- $(.ci/find_cabal_bin.sh clash-testsuite clash-testsuite x) -j${THREADS} -p .SystemVerilog --hide-successes --no-modelsim --no-vivado
- bin/clash-testsuite:clash-testsuite -j$THREADS -p .SystemVerilog --hide-successes --no-modelsim --no-vivado

# Vivado is quite slow, so we only run a subset of the tests on development branches
# with it. The full testsuite gets run with Vivado every night on 'master'.
suite:cores:
extends: .test-cache-local
script:
- source /opt/tools/Xilinx/Vivado/2022.1/settings64.sh
- $(.ci/find_cabal_bin.sh clash-testsuite clash-testsuite x) -j$THREADS -p Cores --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
- bin/clash-testsuite:clash-testsuite -j$THREADS -p Cores --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
tags:
- local
- vivado-2022.1-standard
Expand Down Expand Up @@ -191,6 +191,7 @@ ffi:example:
script:
- cd clash-ffi/example && ./run-iverilog.sh
after_script:
- export THREADS=$(./.ci/effective_cpus.sh)
- tar -cf - /root/.cabal | zstd -T${THREADS} -3 > cache.tar.zst

# Tests run on local fast machines with Vivado installed. We only run these at night
Expand All @@ -207,7 +208,7 @@ suite:vivado:verilog:
extends: .test-cache-local-nightly
script:
- source /opt/tools/Xilinx/Vivado/2022.1/settings64.sh
- $(.ci/find_cabal_bin.sh clash-testsuite clash-testsuite x) -j$THREADS -p .Verilog --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
- bin/clash-testsuite:clash-testsuite -j$THREADS -p .Verilog --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
tags:
- local
- vivado-2022.1-standard
Expand All @@ -227,7 +228,7 @@ suite:vivado:verilog:
# extends: .test-cache-local-nightly
# script:
# - source /opt/tools/Xilinx/Vivado/2022.1/settings64.sh
# - $(.ci/find_cabal_bin.sh clash-testsuite clash-testsuite x) -j$THREADS -p .VHDL --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
# - bin/clash-testsuite:clash-testsuite -j$THREADS -p .VHDL --hide-successes --no-modelsim --no-ghdl --no-iverilog --no-verilator --no-symbiyosys
# tags:
# - local
# - vivado-2022.1-standard
43 changes: 34 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ jobs:
matrix:
os: ["macOS", "windows"]
ghc: ["8.6", "8.8", "8.10", "9.0", "9.2", "9.4", "9.6", "9.8"]
include:
- stack: latest

# The latest stack image uses aarch64, for which this GHC doesn't
# exist
- os: macOS
ghc: 8.6
stack: 2.11.1

# The latest stack image uses aarch64, for which this GHC doesn't
# exist
- os: macOS
ghc: 8.8
stack: 2.11.1

# The latest stack image gives error:
# ld: unknown option: --version
# <no location info>: error:
# Warning: Couldn't figure out LLVM version!
# Make sure you have installed LLVM between [9 and 13)
- os: macOS
ghc: 9.0
stack: 2.11.1

exclude:
# Some tests fail with a mysterious -11 error code.
- os: macOS
Expand All @@ -38,12 +62,13 @@ jobs:
ghc: 9.0

steps:
- uses: actions/checkout@v3
- uses: haskell/actions/setup@v2
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
enable-stack: true
stack-no-global: true
stack-version: ${{ matrix.stack }}

- name: Install IVerilog (macOS)
if: matrix.os == 'macOS'
Expand All @@ -62,7 +87,7 @@ jobs:
- name: Cache (Windows)
if: ${{ runner.os == 'Windows' }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
# On windows we have to use "\" as a path separator, otherwise caching fails
path: |
Expand All @@ -71,7 +96,7 @@ jobs:
restore-keys: ${{ matrix.os }}-${{ matrix.ghc }}-
- name: Cache (non-Windows)
if: ${{ runner.os != 'Windows' }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell.outputs.stack-root }}/snapshots
Expand Down Expand Up @@ -115,7 +140,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: [ "8.6.5", "9.0.2", "9.6.2" ]
ghc: [ "8.6.5", "9.0.2", "9.6.6" ]
include:
- multiple_hidden: yes

Expand All @@ -129,7 +154,7 @@ jobs:

# Run steps inside the clash CI docker image
container:
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20240726
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20241008

env:
THREADS: 2
Expand All @@ -140,7 +165,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.event.pull_request.head.ref }}
Expand All @@ -157,7 +182,7 @@ jobs:
mv cabal.project.freeze frozen
- name: Restore Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
dist-newstyle
Expand Down Expand Up @@ -209,7 +234,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check dependencies for failures
run: |
Expand Down
13 changes: 2 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
default:
# Make all tasks interruptible by default
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure

include:
- '/.ci/gitlab/common.yml'
- '/.ci/gitlab/publish.yml'
Expand Down Expand Up @@ -42,10 +33,10 @@ tests:
- GHC_VERSION: 9.8.2
RUN_TESTS: "always"

- GHC_VERSION: 9.6.4
- GHC_VERSION: 9.6.6
RUN_TESTS: "always"

- GHC_VERSION: [9.4.6, 9.2.8]
- GHC_VERSION: [9.4.8, 9.2.8]
RUN_TESTS: "nightly"

- GHC_VERSION: 9.0.2
Expand Down

0 comments on commit 851f35f

Please sign in to comment.