From 0a5a9032102222247424a91355d23dfbbfb9ba47 Mon Sep 17 00:00:00 2001 From: Alistair Date: Wed, 11 Oct 2023 18:35:52 +0100 Subject: [PATCH] Git: Add CI GitHub workflow --- .github/workflows/ci.yml | 133 +++++++++++++++++++++++++++++++++++++++ .gitignore | 2 +- Makefile | 15 +++++ package-lock.json | 30 ++++++++- package.json | 2 +- 5 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..0a8d35f5a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,133 @@ +name: Continuous Integration + +on: + pull_request: + push: + branches: [main] + +jobs: + fmt: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + override: true + components: rustfmt + - uses: luisnquin/setup-alejandra@v1.0.0 + + - name: Format (rustfmt) + run: make fmt-rust-check + + - name: Format (prettier) + run: npx prettier --check . + + - name: Format (Nix) + run: make fmt-nix-check + + build: + name: Build (Cargo) + runs-on: ubuntu-latest + needs: fmt + steps: + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + override: true + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Build + run: cargo build + + build-docs: + name: Build Documentation + runs-on: ubuntu-latest + needs: fmt + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: npm + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + - name: Configure npm cache + uses: actions/cache@v3 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - run: npm ci + + - name: Build with VitePress + run: npm run docs:build + + build-sdk: + name: Build TypeScript SDK + runs-on: ubuntu-latest + needs: fmt + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: npm + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + - name: Configure npm cache + uses: actions/cache@v3 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - run: npm ci + + - name: Build + run: cd packages/jstz && npm run build + + build-nix: + name: Build (Nix) + runs-on: ubuntu-latest + needs: [build, build-sdk, build-docs] + 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 Shell + run: nix develop --command bash -c "echo 'Hello World'" + + - name: Build + run: nix build + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: kernel + path: result/lib diff --git a/.gitignore b/.gitignore index e7ad2d909..55b08de44 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,4 @@ node_modules/ **/.vitepress/cache **/.vitepress/dist -**/dist \ No newline at end of file +**/dist 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 diff --git a/package-lock.json b/package-lock.json index 8bc7c86f6..d18dcc135 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,10 +14,10 @@ ], "dependencies": { "@tezos/jstz": "^0.0.0", - "@tezos/jstz-types": "^0.0.0", - "esbuild": "^0.19.4" + "@tezos/jstz-types": "^0.0.0" }, "devDependencies": { + "esbuild": "^0.19.4", "prettier": "^3.0.3", "typescript": "^5.2.2", "vitepress": "^1.0.0-rc.20" @@ -28,6 +28,9 @@ "version": "0.0.0", "dependencies": { "@tezos/jstz": "^0.0.0" + }, + "devDependencies": { + "esbuild": "^0.19.4" } }, "examples/hello-world": { @@ -259,6 +262,7 @@ "cpu": [ "arm" ], + "dev": true, "optional": true, "os": [ "android" @@ -274,6 +278,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "android" @@ -289,6 +294,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "android" @@ -304,6 +310,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -319,6 +326,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -334,6 +342,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "freebsd" @@ -349,6 +358,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "freebsd" @@ -364,6 +374,7 @@ "cpu": [ "arm" ], + "dev": true, "optional": true, "os": [ "linux" @@ -379,6 +390,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -394,6 +406,7 @@ "cpu": [ "ia32" ], + "dev": true, "optional": true, "os": [ "linux" @@ -409,6 +422,7 @@ "cpu": [ "loong64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -424,6 +438,7 @@ "cpu": [ "mips64el" ], + "dev": true, "optional": true, "os": [ "linux" @@ -439,6 +454,7 @@ "cpu": [ "ppc64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -454,6 +470,7 @@ "cpu": [ "riscv64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -469,6 +486,7 @@ "cpu": [ "s390x" ], + "dev": true, "optional": true, "os": [ "linux" @@ -484,6 +502,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -499,6 +518,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "netbsd" @@ -514,6 +534,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "openbsd" @@ -529,6 +550,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "sunos" @@ -544,6 +566,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "win32" @@ -559,6 +582,7 @@ "cpu": [ "ia32" ], + "dev": true, "optional": true, "os": [ "win32" @@ -574,6 +598,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "win32" @@ -942,6 +967,7 @@ "version": "0.19.4", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.4.tgz", "integrity": "sha512-x7jL0tbRRpv4QUyuDMjONtWFciygUxWaUM1kMX2zWxI0X2YWOt7MSA0g4UdeSiHM8fcYVzpQhKYOycZwxTdZkA==", + "dev": true, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" diff --git a/package.json b/package.json index 3ec56b3d2..016eb738e 100644 --- a/package.json +++ b/package.json @@ -26,4 +26,4 @@ "vitepress": "^1.0.0-rc.20", "esbuild": "^0.19.4" } -} \ No newline at end of file +}