Skip to content

Commit

Permalink
refactor: use Nix to test, lint and build
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Nov 2, 2023
1 parent 6121e6c commit 79dcc11
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 45 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
- uses: cachix/install-nix-action@v22
with:
go-version: 1.21.0
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Test
uses: joerdav/[email protected]
with:
task: test-cover
run: nix develop --command xc test-cover

- name: Copy coverage.out to temp
run: cp coverage.out $RUNNER_TEMP
Expand All @@ -35,33 +32,32 @@ jobs:
if: |
github.event_name == 'push'
- name: Build
run: nix build

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
- uses: cachix/install-nix-action@v22
with:
go-version: 1.21.0
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint
uses: golangci/golangci-lint-action@v3
uses: nix develop --command xc lint

ensure-generated:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
- uses: cachix/install-nix-action@v22
with:
go-version: 1.21.0
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Generate
uses: joerdav/[email protected]
with:
task: generate
uses: nix develop --command xc generate

- name: Ensure clean
run: git diff --exit-code
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ gofmt -s -w .
### lint

```sh
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.54 golangci-lint run -v
golangci-lint run --verbose
```

### release
Expand Down Expand Up @@ -138,19 +138,3 @@ Directory: docs
npm run build
```

### docker-build

Build a Docker container with a full development environment and Neovim setup for testing the LSP.

```
docker build -t templ:latest .
```

### docker-run

Run a Docker development container in the current directory.

```
docker run -p 7474:7474 -v `pwd`:/templ -it --rm templ:latest
```

5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
inherit system;
pkgs = import nixpkgs { inherit system; };
});
in rec {
in
rec {
packages = forAllSystems ({ pkgs, ... }: rec {
default = templ;

Expand Down Expand Up @@ -66,7 +67,9 @@
devShell = forAllSystems ({ system, pkgs }:
pkgs.mkShell {
buildInputs = with pkgs; [
(golangci-lint.override { buildGoModule = buildGo121Module; })
go_1_21
gofmt
goreleaser
nodejs
xc.packages.${system}.xc
Expand Down

0 comments on commit 79dcc11

Please sign in to comment.