diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..9779822b0 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -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 diff --git a/Makefile b/Makefile index 67392295a..e35fa75a4 100644 --- a/Makefile +++ b/Makefile @@ -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