Skip to content

Commit 93fb5d8

Browse files
feat: Use Nix & Shipfox & Just for DevXP (#77)
* feat: add Nix flake for Go 1.23 development environment * feat: add .envrc and Justfile for environment setup; remove obsolete scripts * feat: add antlr to Nix flake dependencies * chore: update ANTLR version in generated files to 4.13.2 * feat: add GitHub Actions for environment setup and release management; remove obsolete workflows * chore: remove SPEAKEASY_API_KEY from workflows to streamline environment variables * refactor: simplify range checks in hover functions and update variable end position * refactor: improve error handling and logging across multiple files * feat: Update flake.nix Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 17ad127 commit 93fb5d8

30 files changed

+475
-153
lines changed

.envrc

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

.github/actions/default/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup Env
2+
description: Setup Env for Linux x64
3+
inputs:
4+
token:
5+
description: 'A Github PAT'
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Install Nix
11+
uses: cachix/install-nix-action@v31
12+
- name: Cache dependencies
13+
uses: nix-community/cache-nix-action@v6
14+
with:
15+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/flake.nix', '**/flake.lock') }}
16+
restore-prefixes-first-match: nix-${{ runner.os }}-
17+
- name: Load dependencies
18+
shell: bash
19+
run: nix develop --install
20+
- uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.cache/go-build
24+
/tmp/go/pkg/mod/
25+
key: ${{ runner.os }}-${{ github.job }}-go-${{ hashFiles('**/go.sum') }}
26+
restore-keys: |
27+
${{ runner.os }}-${{ github.job }}-go-

.github/actions/env/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Setup Env
2+
description: Setup Env for Linux x64
3+
inputs:
4+
token:
5+
description: 'A Github PAT'
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Set up QEMU
11+
uses: docker/setup-qemu-action@v3
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v3
14+
- name: "Put back the git branch into git (Earthly uses it for tagging)"
15+
shell: bash
16+
run: |
17+
branch=""
18+
if [ -n "$GITHUB_HEAD_REF" ]; then
19+
branch="$GITHUB_HEAD_REF"
20+
else
21+
branch="${GITHUB_REF##*/}"
22+
fi
23+
git checkout -b "$branch" || true
24+

.github/workflows/checks.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Default
2+
on:
3+
merge_group:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
pull_request:
9+
types: [ assigned, opened, synchronize, reopened, labeled ]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
PR:
17+
if: github.event_name == 'pull_request'
18+
name: Check PR Title
19+
runs-on: ubuntu-latest
20+
permissions:
21+
statuses: write
22+
steps:
23+
- uses: amannn/action-semantic-pull-request@v5
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
Dirty:
28+
runs-on: "shipfox-4vcpu-ubuntu-2404"
29+
env:
30+
GOPATH: /tmp/go
31+
GOLANGCI_LINT_CACHE: /tmp/golangci-lint
32+
steps:
33+
- uses: 'actions/checkout@v4'
34+
with:
35+
fetch-depth: 0
36+
- name: Setup Env
37+
uses: ./.github/actions/default
38+
with:
39+
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
40+
- run: >
41+
nix develop --impure --command just pre-commit
42+
- name: Get changed files
43+
id: changed-files
44+
shell: bash
45+
run: |
46+
hasChanged=$(git status --porcelain)
47+
if (( $(echo ${#hasChanged}) != 0 )); then
48+
git status
49+
echo "There are changes in the repository"
50+
git diff
51+
exit 1
52+
fi
53+
54+
Tests:
55+
runs-on: "shipfox-4vcpu-ubuntu-2404"
56+
env:
57+
GOPATH: /tmp/go
58+
steps:
59+
- uses: 'actions/checkout@v4'
60+
with:
61+
fetch-depth: 0
62+
- name: Setup Env
63+
uses: ./.github/actions/default
64+
with:
65+
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
66+
- run: >
67+
nix develop --impure --command just tests
68+
- name: Upload coverage reports to Codecov with GitHub Action
69+
uses: codecov/codecov-action@v5.4.3
70+
env:
71+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
72+
73+
GoReleaser:
74+
runs-on: "shipfox-4vcpu-ubuntu-2404"
75+
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group'
76+
needs:
77+
- Dirty
78+
steps:
79+
- name: Set up QEMU
80+
uses: docker/setup-qemu-action@v3
81+
- name: Set up Docker Buildx
82+
uses: docker/setup-buildx-action@v3
83+
- uses: earthly/actions-setup@v1
84+
with:
85+
github-token: ${{ secrets.GITHUB_TOKEN }}
86+
version: "latest"
87+
- uses: 'actions/checkout@v4'
88+
with:
89+
fetch-depth: 0
90+
- name: Setup Env
91+
uses: ./.github/actions/default
92+
with:
93+
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
94+
- name: Set up QEMU
95+
uses: docker/setup-qemu-action@v3
96+
- name: Set up Docker Buildx
97+
uses: docker/setup-buildx-action@v3
98+
- name: Login to GitHub Container Registry
99+
uses: docker/login-action@v3
100+
with:
101+
registry: ghcr.io
102+
username: "NumaryBot"
103+
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
104+
- run: >
105+
nix develop --impure --command just release-ci
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
108+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.github/workflows/release.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/releases.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*.*.*'
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
GoReleaser:
11+
runs-on: "shipfox-4vcpu-ubuntu-2404"
12+
steps:
13+
- uses: 'actions/checkout@v4'
14+
with:
15+
fetch-depth: 0
16+
- name: Setup Env
17+
uses: ./.github/actions/default
18+
with:
19+
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
- name: Login to GitHub Container Registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: "NumaryBot"
29+
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
30+
- run: >
31+
nix develop --impure --command just release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
34+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

Justfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
set dotenv-load
2+
3+
default:
4+
@just --list
5+
6+
pre-commit: generate tidy lint
7+
pc: pre-commit
8+
9+
lint:
10+
@golangci-lint run --fix --build-tags it --timeout 5m
11+
12+
tidy:
13+
@go mod tidy
14+
15+
generate:
16+
@antlr4 -Dlanguage=Go Lexer.g4 Numscript.g4 -o internal/parser/antlrParser -package antlrParser
17+
@mv internal/parser/antlrParser/_lexer.go internal/parser/antlrParser/lexer.go
18+
19+
tests:
20+
@go test -race -covermode=atomic \
21+
-coverprofile coverage.txt \
22+
./...
23+
24+
release-local:
25+
@goreleaser release --nightly --skip=publish --clean
26+
27+
release-ci:
28+
@goreleaser release --nightly --clean
29+
30+
release:
31+
@goreleaser release --clean

flake.lock

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)