Skip to content

Commit

Permalink
Git: Add CI/CD GitHub workflow using Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
johnyob committed Oct 12, 2023
1 parent 493f914 commit 297df61
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Format and Build

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: trilitech-jstz
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Format (rustfmt)
run: nix develop --command bash -c "make fmt-rust-check"

- name: Format (prettier)
run: nix develop --command bash -c "make fmt-js-check"

- name: Format (Nix)
run: nix develop --command bash -c "make fmt-nix-check"

build-nix:
name: Build `jstz_kernel` (Nix)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: trilitech-jstz
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Build `jstz_kernel`
run: nix build

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: kernel
path: result/lib
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,32 @@ clean:
rm -f result
rm -rf logs

.PHONY: fmt-nix-check
fmt-nix-check:
@alejandra check ./

.PHONY: fmt-nix
fmt-nix:
@alejandra ./

.PHONY: fmt-rust-check
fmt-rust-check:
@cargo fmt --check

.PHONY: fmt-rust
fmt-rust:
@cargo fmt

.PHONY: fmt-js-check
fmt-js-check:
npm run check:format

.PHONY: fmt-js
fmt-js:
npm run format

.PHONY: fmt
fmt: fmt-nix fmt-rust fmt-js

.PHONY: fmt-check
fmt: fmt-nix-check fmt-rust-check fmt-js-check

0 comments on commit 297df61

Please sign in to comment.