Skip to content

Commit 4562979

Browse files
committed
Refactor the CI setup
This merges compiler and stdlib jobs into one, and we test against fewer different Linux distributions. In addition, the Linux images are built ahead of time (once more) to reduce time spent installing packages, and to make the builds more reliable. In addition, the CI setup is refactored to be simpler. All things combined should hopefully reduce CI build times by quite a bit.
1 parent aafb204 commit 4562979

File tree

16 files changed

+213
-283
lines changed

16 files changed

+213
-283
lines changed

.github/workflows/container.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: CI container
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
description: 'The name of the image to build'
8+
required: true
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
NAMESPACE: inko-lang/ci
13+
14+
jobs:
15+
container:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: docker/login-action@v2
23+
with:
24+
registry: ${{ env.REGISTRY }}
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
- uses: docker/build-push-action@v4
28+
with:
29+
context: ci/docker/${{ inputs.name }}
30+
push: true
31+
tags: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}:${{ inputs.name }}

.github/workflows/containers.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: CI containers
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'ci/**/*'
10+
11+
jobs:
12+
arch:
13+
uses: ./.github/workflows/container.yml
14+
with:
15+
name: 'arch'
16+
debian:
17+
uses: ./.github/workflows/container.yml
18+
with:
19+
name: 'debian'
20+
fedora:
21+
uses: ./.github/workflows/container.yml
22+
with:
23+
name: 'fedora'
24+
ubuntu:
25+
uses: ./.github/workflows/container.yml
26+
with:
27+
name: 'ubuntu'

.github/workflows/freebsd.yml

+3-49
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ env:
1111
# Due to https://github.com/cross-platform-actions/action/issues/29, jobs should
1212
# use QEMU, instead of xhyve.
1313
jobs:
14-
compiler:
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
version:
19-
- '1.70'
14+
test:
2015
runs-on: macos-latest
2116
steps:
2217
- uses: actions/checkout@v4
@@ -25,7 +20,7 @@ jobs:
2520
path: |
2621
${{ env.CARGO_HOME }}
2722
target
28-
key: freebsd-${{ matrix.version }}
23+
key: freebsd
2924
- name: Run tests
3025
uses: cross-platform-actions/[email protected]
3126
with:
@@ -34,45 +29,4 @@ jobs:
3429
environment_variables: 'CARGO_HOME LIBRARY_PATH CARGO_REGISTRIES_CRATES_IO_PROTOCOL'
3530
hypervisor: qemu
3631
image_url: 'https://github.com/inko-lang/freebsd-builder/releases/download/v0.6.5/freebsd-13.2-x86-64.qcow2'
37-
run: |
38-
./scripts/rust.sh ${{ matrix.version }}
39-
setenv PATH "${CARGO_HOME}/bin:${PATH}"
40-
echo "::group::Running tests"
41-
cargo test
42-
echo "::endgroup::"
43-
44-
std:
45-
strategy:
46-
fail-fast: false
47-
matrix:
48-
version:
49-
- '1.70'
50-
runs-on: macos-latest
51-
needs:
52-
- compiler
53-
steps:
54-
- uses: actions/checkout@v4
55-
- uses: actions/cache@v4
56-
with:
57-
path: |
58-
${{ env.CARGO_HOME }}
59-
target
60-
key: freebsd-${{ matrix.version }}
61-
- name: Run tests
62-
uses: cross-platform-actions/[email protected]
63-
with:
64-
operating_system: freebsd
65-
version: '13.2'
66-
environment_variables: 'CARGO_HOME LIBRARY_PATH CARGO_REGISTRIES_CRATES_IO_PROTOCOL'
67-
hypervisor: qemu
68-
image_url: 'https://github.com/inko-lang/freebsd-builder/releases/download/v0.6.5/freebsd-13.2-x86-64.qcow2'
69-
run: |
70-
./scripts/rust.sh ${{ matrix.version }}
71-
setenv PATH "${CARGO_HOME}/bin:${PATH}"
72-
echo "::group::Compiling"
73-
cargo build
74-
echo "::endgroup::"
75-
echo "::group::Running tests"
76-
cd std
77-
../target/debug/inko test
78-
echo "::endgroup::"
32+
run: ./ci/freebsd.sh

.github/workflows/lint.yml

+10-22
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ name: Run linters
33
on:
44
workflow_call:
55

6-
env:
7-
# This directory must be named differently from `.cargo`, otherwise it will
8-
# conflict with our local Cargo configuration.
9-
CARGO_HOME: ${{ github.workspace }}/.cargo-home
10-
116
jobs:
127
vale:
138
runs-on: ubuntu-latest
@@ -36,39 +31,32 @@ jobs:
3631
- run: git config --global --add safe.directory $PWD
3732
- run: gitlint --commits "HEAD~9..HEAD"
3833

39-
# Clippy uses a specific version as its lints change over time, which could
40-
# result in random unrelated CI failures. We'll bump this version every now
41-
# and then when needed.
4234
cargo-clippy:
4335
runs-on: ubuntu-latest
36+
container:
37+
image: ghcr.io/inko-lang/ci:fedora
4438
steps:
4539
- uses: actions/checkout@v4
4640
- uses: actions/cache@v4
4741
with:
4842
path: |
4943
${{ env.CARGO_HOME }}
5044
target
51-
key: ubuntu-1.74
52-
- name: Installing Rust
53-
run: ./scripts/rust.sh 1.74
54-
- name: Installing dependencies
55-
run: sudo ./scripts/deps.sh ubuntu:latest
56-
- name: Installing clippy
57-
run: rustup component add clippy
58-
- run: 'cargo clippy -- -D warnings'
45+
key: fedora
46+
- name: Run clippy
47+
run: 'cargo clippy -- -D warnings'
5948

6049
cargo-fmt:
6150
runs-on: ubuntu-latest
51+
container:
52+
image: ghcr.io/inko-lang/ci:fedora
6253
steps:
6354
- uses: actions/checkout@v4
6455
- uses: actions/cache@v4
6556
with:
6657
path: |
6758
${{ env.CARGO_HOME }}
6859
target
69-
key: ubuntu-1.74
70-
- name: Installing Rust
71-
run: ./scripts/rust.sh 1.74
72-
- name: Installing rustfmt
73-
run: rustup component add rustfmt
74-
- run: 'cargo fmt --all --check'
60+
key: fedora
61+
- name: Run rustfmt
62+
run: 'cargo fmt --all --check'

.github/workflows/linux.yml

+13-53
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,30 @@ name: Linux tests
33
on:
44
workflow_call:
55

6-
env:
7-
CARGO_HOME: ${{ github.workspace }}/.cargo-home
8-
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
9-
DEBIAN_FRONTEND: noninteractive
10-
TZ: UTC
11-
126
jobs:
13-
compiler:
7+
test:
148
strategy:
159
fail-fast: false
1610
matrix:
17-
version:
18-
- '1.70'
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v4
22-
- uses: actions/cache@v4
23-
with:
24-
path: |
25-
${{ env.CARGO_HOME }}
26-
target
27-
key: ubuntu-${{ matrix.version }}
28-
- name: Installing dependencies
29-
run: sudo ./scripts/deps.sh ubuntu:latest
30-
- name: Installing Rust
31-
run: ./scripts/rust.sh ${{ matrix.version }}
32-
- name: Running tests
33-
run: cargo test
34-
35-
std:
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
version:
40-
- '1.70'
4111
image:
42-
- archlinux:latest
43-
- debian:11
44-
- debian:latest
45-
- fedora:37
46-
- fedora:38
47-
- fedora:latest
48-
- ubuntu:20.04
49-
- ubuntu:latest
12+
- arch
13+
- debian
14+
- fedora
15+
- ubuntu
5016
runs-on: ubuntu-latest
5117
container:
52-
image: ${{ matrix.image }}
53-
needs:
54-
- compiler
18+
image: ghcr.io/inko-lang/ci:${{ matrix.image }}
5519
steps:
5620
- uses: actions/checkout@v4
5721
- uses: actions/cache@v4
5822
with:
5923
path: |
6024
${{ env.CARGO_HOME }}
6125
target
62-
key: ${{ matrix.image }}-${{ matrix.version }}
63-
- name: Installing dependencies
64-
run: ./scripts/deps.sh ${{ matrix.image }}
65-
- name: Installing Rust
66-
run: ./scripts/rust.sh ${{ matrix.version }}
67-
- name: Compiling
68-
run: cargo build
69-
- name: Running tests
70-
run: |
71-
cd std
72-
../target/debug/inko test
26+
key: ${{ matrix.image }}
27+
- name: Show version info
28+
run: rustc --version
29+
- name: Run compiler tests
30+
run: cargo test
31+
- name: Run stdlib tests
32+
run: 'cd std && cargo run -- test'

.github/workflows/mac.yml

+7-40
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ env:
88
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
99

1010
jobs:
11-
compiler:
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
version:
16-
- '1.70'
11+
test:
1712
runs-on: macos-latest
1813
steps:
1914
- uses: actions/checkout@v4
@@ -22,38 +17,10 @@ jobs:
2217
path: |
2318
${{ env.CARGO_HOME }}
2419
target
25-
key: mac-${{ matrix.version }}
26-
- name: Installing dependencies
27-
run: ./scripts/deps.sh mac
28-
- name: Installing Rust
29-
run: ./scripts/rust.sh ${{ matrix.version }}
30-
- name: Running tests
20+
key: mac
21+
- name: Install dependencies
22+
run: ./ci/mac.sh
23+
- name: Run compiler tests
3124
run: cargo test
32-
33-
std:
34-
strategy:
35-
fail-fast: false
36-
matrix:
37-
version:
38-
- '1.70'
39-
runs-on: macos-latest
40-
needs:
41-
- compiler
42-
steps:
43-
- uses: actions/checkout@v4
44-
- uses: actions/cache@v4
45-
with:
46-
path: |
47-
${{ env.CARGO_HOME }}
48-
target
49-
key: mac-${{ matrix.version }}
50-
- name: Installing dependencies
51-
run: ./scripts/deps.sh mac
52-
- name: Installing Rust
53-
run: ./scripts/rust.sh ${{ matrix.version }}
54-
- name: Compiling
55-
run: cargo build
56-
- name: Running tests
57-
run: |
58-
cd std
59-
../target/debug/inko test
25+
- name: Run stdlib tests
26+
run: 'cd std && cargo run -- test'

.github/workflows/release.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868

6969
runtimes:
7070
runs-on: ubuntu-latest
71+
image: ghcr.io/inko-lang/ci:fedora
7172
needs:
7273
- lints
7374
- linux
@@ -79,10 +80,6 @@ jobs:
7980
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
8081
steps:
8182
- uses: actions/checkout@v4
82-
- name: Installing dependencies
83-
run: sudo ./scripts/deps.sh ubuntu:latest
84-
- name: Installing Rust
85-
run: ./scripts/rust.sh 1.70
8683
- name: Generating runtimes
8784
run: make runtimes
8885

ast/src/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,7 @@ impl Parser {
17691769
}
17701770
}
17711771

1772+
#[cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_clone))]
17721773
fn string_text(&mut self, start: Token) -> StringText {
17731774
let mut value = start.value;
17741775
let mut end_loc = start.location.clone();

ci/docker/arch/Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM archlinux:latest
2+
3+
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL sparse
4+
ENV LLVM_VERSION 15
5+
ENV RUST_VERSION 1.70
6+
7+
ENV PATH /opt/cargo/bin:$PATH
8+
ENV CARGO_HOME /opt/cargo
9+
ENV RUSTUP_HOME /opt/rustup
10+
11+
RUN pacman-key --init && \
12+
pacman-key --populate && \
13+
pacman -Sy --noconfirm archlinux-keyring && \
14+
pacman -Syu --noconfirm rustup tar git base-devel curl llvm15
15+
16+
RUN rustup toolchain install --profile minimal $RUST_VERSION && \
17+
rustup default $RUST_VERSION

ci/docker/debian/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM debian:12
2+
3+
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL sparse
4+
ENV LLVM_VERSION 15
5+
ENV RUST_VERSION 1.70
6+
7+
ENV PATH /opt/cargo/bin:$PATH
8+
ENV CARGO_HOME /opt/cargo
9+
ENV RUSTUP_HOME /opt/rustup
10+
11+
RUN apt-get update --quiet && apt-get install --quiet --yes \
12+
build-essential tar git curl \
13+
llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \
14+
libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev
15+
16+
RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \
17+
--silent --show-error --fail "https://sh.rustup.rs" | \
18+
sh -s -- --quiet -y --no-modify-path --profile minimal \
19+
--component clippy,rustfmt --default-toolchain $RUST_VERSION

0 commit comments

Comments
 (0)