Skip to content

Commit 3668484

Browse files
committed
build: converting from Docker -> Nix
1 parent f10b76c commit 3668484

26 files changed

+454
-119
lines changed

.cargo/config.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# From https://github.com/BurntSushi/ripgrep/blob/master/.cargo/config.toml
2+
3+
# Do the same for MUSL targets. At the time of writing (2023-10-23), this is
4+
# the default. But the plan is for the default to change to dynamic linking.
5+
# The whole point of MUSL with respect to ripgrep is to create a fully
6+
# statically linked executable.
7+
#
8+
# See: https://github.com/rust-lang/compiler-team/issues/422
9+
# See: https://github.com/rust-lang/compiler-team/issues/422#issuecomment-812135847
10+
[target.x86_64-unknown-linux-musl]
11+
rustflags = [
12+
"-C", "target-feature=+crt-static",
13+
"-C", "link-self-contained=yes",
14+
]
15+
16+
[target.aarch64-unknown-linux-musl]
17+
rustflags = [
18+
"-C", "target-feature=+crt-static",
19+
"-C", "link-self-contained=yes",
20+
]

.copier-answers.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changes here will be overwritten by Copier
2+
_commit: v1.6.1
3+
_src_path: https://github.com/DeveloperC286/template
4+
project_name: monkey_interpreter
5+
uses_git: false

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/renovate.json5

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,18 @@
44
"config:best-practices"
55
],
66
"automerge": true,
7-
"dockerfile": {
8-
"managerFilePatterns": [
9-
"/(^|/|\\.)Dockerfile$/",
10-
"/(^|/)Dockerfile[^/]*$/"
11-
]
7+
"github-actions": {
8+
"enabled": false
9+
},
10+
"nix": {
11+
"enabled": true,
12+
"lockFileMaintenance": {
13+
"enabled": true,
14+
"commitMessageAction": "update",
15+
"commitMessageTopic": "Nix flake lock"
16+
}
1217
},
1318
"customManagers": [
14-
{
15-
"customType": "regex",
16-
"managerFilePatterns": [
17-
"/(^|/|\\.)Dockerfile$/",
18-
"/(^|/)Dockerfile[^/]*$/"
19-
],
20-
"matchStrings": [
21-
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s.+_VERSION=\"(?<currentValue>.*?)\"\\s"
22-
]
23-
},
2419
{
2520
"customType": "regex",
2621
"managerFilePatterns": [
@@ -36,18 +31,6 @@
3631
"datasourceTemplate": "repology",
3732
"depNameTemplate": "alpine_{{alpineMajor}}_{{alpineMinor}}/{{name}}",
3833
"versioningTemplate": "loose"
39-
},
40-
{
41-
"customType": "regex",
42-
"managerFilePatterns": [
43-
"/(^|/|\\.)Makefile$/",
44-
"/(^|/)Makefile[^/]*$/"
45-
],
46-
"matchStrings": [
47-
"# renovate: depName=(?<depName>.*?)\\s.+_VERSION=(?<currentValue>[a-z0-9.-]+)(?:@(?<currentDigest>sha256:[a-f0-9]+))?"
48-
],
49-
"datasourceTemplate": "docker",
50-
"versioningTemplate": "docker"
5134
}
5235
]
5336
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Continuous Delivery (CD)
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
publish-binary:
14+
name: Publish Binary
15+
runs-on: ${{ matrix.architecture }}
16+
strategy:
17+
matrix:
18+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
19+
steps:
20+
- name: Checkout code.
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
22+
- name: Setup Nix.
23+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
24+
- name: Publish binary.
25+
run: nix develop -c make publish-binary RELEASE="${GITHUB_REF_NAME}"
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by GitHub Actions.
28+
29+
publish-crate:
30+
name: Publish Crate
31+
runs-on: ubuntu-24.04
32+
steps:
33+
- name: Checkout code.
34+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
35+
- name: Setup Nix.
36+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
37+
- name: Publish crate.
38+
run: nix develop -c make publish-crate
39+
env:
40+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
41+
42+
publish-docker-image:
43+
name: Publish Docker Image (${{ matrix.platform }})
44+
runs-on: ${{ matrix.runner }}
45+
needs: [publish-binary]
46+
strategy:
47+
matrix:
48+
include:
49+
- platform: linux/amd64
50+
runner: ubuntu-24.04
51+
target: x86_64-unknown-linux-musl
52+
suffix: amd64
53+
- platform: linux/arm64
54+
runner: ubuntu-24.04-arm
55+
target: aarch64-unknown-linux-musl
56+
suffix: arm64
57+
steps:
58+
- name: Checkout code.
59+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
62+
- name: Login to GitHub Container Registry
63+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
64+
with:
65+
registry: ghcr.io
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
- name: Publish Docker Image
69+
run: make publish-docker-image RELEASE="${GITHUB_REF_NAME}" PLATFORM="${{ matrix.platform }}" TARGET="${{ matrix.target }}" SUFFIX="${{ matrix.suffix }}"
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
73+
publish-docker-manifest:
74+
name: Publish Docker Manifest
75+
runs-on: ubuntu-24.04
76+
needs: [publish-docker-image]
77+
steps:
78+
- name: Checkout code.
79+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
80+
- name: Set up Docker Buildx
81+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
82+
- name: Login to GitHub Container Registry
83+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
84+
with:
85+
registry: ghcr.io
86+
username: ${{ github.actor }}
87+
password: ${{ secrets.GITHUB_TOKEN }}
88+
- name: Publish Docker Manifest
89+
run: make publish-docker-manifest RELEASE="${GITHUB_REF_NAME}"

.github/workflows/continuous-integration.yml

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,84 @@ permissions:
88
jobs:
99
formatting:
1010
name: Formatting
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.architecture }}
1212
strategy:
1313
matrix:
14-
language: [rust, shell]
14+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
15+
language: [rust, shell, python]
1516
steps:
1617
- name: Checkout code.
1718
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
19+
- name: Setup Nix.
20+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
1821
- name: Check formatting.
19-
run: make check-${{ matrix.language }}-formatting
22+
run: nix develop -c make check-${{ matrix.language }}-formatting
23+
2024
linting:
2125
name: Linting
22-
runs-on: ubuntu-latest
26+
runs-on: ${{ matrix.architecture }}
2327
strategy:
2428
matrix:
25-
language: [rust]
29+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
30+
language: [rust, shell]
2631
steps:
2732
- name: Checkout code.
2833
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
34+
- name: Setup Nix.
35+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
2936
- name: Check linting.
30-
run: make check-${{ matrix.language }}-linting
37+
run: nix develop -c make check-${{ matrix.language }}-linting
38+
39+
scripts-permissions:
40+
name: Scripts Permissions
41+
runs-on: ${{ matrix.architecture }}
42+
strategy:
43+
matrix:
44+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
45+
steps:
46+
- name: Checkout code.
47+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
48+
- name: Check scripts permissions.
49+
run: make check-scripts-permissions
50+
3151
compile:
3252
name: Compile
33-
runs-on: ubuntu-latest
53+
runs-on: ${{ matrix.architecture }}
54+
strategy:
55+
matrix:
56+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
3457
steps:
3558
- name: Checkout code.
3659
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
60+
- name: Setup Nix.
61+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
3762
- name: Compile.
38-
run: make compile
63+
run: nix develop -c make compile
64+
3965
unit-test:
4066
name: Unit Test
41-
runs-on: ubuntu-latest
67+
runs-on: ${{ matrix.architecture }}
68+
strategy:
69+
matrix:
70+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
4271
steps:
4372
- name: Checkout code.
4473
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
74+
- name: Setup Nix.
75+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
4576
- name: Unit test.
46-
run: make unit-test
77+
run: nix develop -c make unit-test
78+
79+
end-to-end-test:
80+
name: End to End Test
81+
runs-on: ${{ matrix.architecture }}
82+
strategy:
83+
matrix:
84+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
85+
steps:
86+
- name: Checkout code.
87+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
88+
- name: Setup Nix.
89+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
90+
- name: End to End test.
91+
run: nix develop -c make end-to-end-test

.github/workflows/conventional-commits.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ permissions:
88
jobs:
99
linting:
1010
name: Linting
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
12+
container:
13+
image: ghcr.io/developerc286/conventional_commits_linter:0.17.0@sha256:d6fb0dfd79c2e06897692bc3f0dc62bcb7ce90a92030c81a3137935516d525d7
1214
steps:
1315
- name: Checkout code.
1416
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1517
with:
1618
ref: ${{ github.event.pull_request.head.sha }}
1719
fetch-depth: 0
1820
- name: Check Conventional Commits linting.
19-
run: make check-conventional-commits-linting FROM="origin/${{ github.base_ref }}"
21+
run: conventional_commits_linter --type angular "origin/${{ github.base_ref }}"

.github/workflows/dogfood.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Dogfood
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
docker:
10+
name: Docker
11+
runs-on: ${{ matrix.architecture }}
12+
strategy:
13+
matrix:
14+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
15+
steps:
16+
- name: Checkout code.
17+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18+
- name: Setup Nix.
19+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
20+
- name: Dogfooding Docker.
21+
run: nix develop -c make dogfood-docker

.github/workflows/git-history.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ permissions:
88
jobs:
99
clean:
1010
name: Clean
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
12+
container:
13+
image: ghcr.io/developerc286/clean_git_history:1.1.5@sha256:b1374591d48393f6b5fcc888f6bc7da05f7d218961f7850112130b1cad78186a
1214
steps:
1315
- name: Checkout code.
1416
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1517
with:
1618
ref: ${{ github.event.pull_request.head.sha }}
1719
fetch-depth: 0
1820
- name: Check clean Git history.
19-
run: make check-clean-git-history FROM="origin/${{ github.base_ref }}"
21+
run: clean_git_history "origin/${{ github.base_ref }}"

.github/workflows/github-actions-workflows.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,30 @@ permissions:
66
contents: read
77

88
jobs:
9-
linting:
10-
name: Linting
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout code.
14-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
15-
- name: Check GitHub Actions workflows linting.
16-
run: make check-github-actions-workflows-linting
179
formatting:
1810
name: Formatting
19-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.architecture }}
12+
strategy:
13+
matrix:
14+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
2015
steps:
2116
- name: Checkout code.
2217
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
18+
- name: Setup Nix.
19+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
2320
- name: Check formatting.
24-
run: make check-yaml-formatting
21+
run: nix develop -c make check-yaml-formatting
22+
23+
linting:
24+
name: Linting
25+
runs-on: ${{ matrix.architecture }}
26+
strategy:
27+
matrix:
28+
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
29+
steps:
30+
- name: Checkout code.
31+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
32+
- name: Setup Nix.
33+
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
34+
- name: Check GitHub Actions workflows linting.
35+
run: nix develop -c make check-github-actions-workflows-linting

0 commit comments

Comments
 (0)