From a9bd5c6de12852a57465244e5bf4dcc057b4b46b Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:29:32 -0500 Subject: [PATCH 1/7] build: use nix in CI --- .github/actions/yarn/action.yml | 13 ++++++++++--- .github/workflows/main.yml | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/actions/yarn/action.yml b/.github/actions/yarn/action.yml index cd88040e6..98c3e0565 100644 --- a/.github/actions/yarn/action.yml +++ b/.github/actions/yarn/action.yml @@ -4,15 +4,22 @@ description: Sets up the Yarn, the Yarn Cache, and installs runs: using: composite steps: - - uses: actions/setup-node@v2 + # Install Cachix + - uses: cachix/install-nix-action@v17 + - name: Setup Cachix + uses: cachix/cachix-action@v10 with: - node-version: "14" + name: saber + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + # Install Node + - uses: actions/setup-node@v3 - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn config get cacheFolder)" shell: bash - name: Yarn Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe73c6379..664a9a347 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +defaults: + run: + shell: nix shell .#env-anchor-idls --command bash {0} + jobs: build: runs-on: ubuntu-latest From 55f4a81e484bc89b1d49204b7c70031e4b4809f1 Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:29:56 -0500 Subject: [PATCH 2/7] no shell --- .github/actions/yarn/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/actions/yarn/action.yml b/.github/actions/yarn/action.yml index 98c3e0565..34edf5fd1 100644 --- a/.github/actions/yarn/action.yml +++ b/.github/actions/yarn/action.yml @@ -17,7 +17,6 @@ runs: - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn config get cacheFolder)" - shell: bash - name: Yarn Cache uses: actions/cache@v3 with: @@ -26,4 +25,3 @@ runs: restore-keys: | ${{ runner.os }}-modules- - run: yarn install - shell: bash From a512d994291a438af53fb4dfdf3ed51ae8870449 Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:34:03 -0500 Subject: [PATCH 3/7] dependencies --- .github/actions/yarn/action.yml | 7 ++++++- .github/workflows/main.yml | 16 +++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/actions/yarn/action.yml b/.github/actions/yarn/action.yml index 34edf5fd1..6d339f220 100644 --- a/.github/actions/yarn/action.yml +++ b/.github/actions/yarn/action.yml @@ -1,6 +1,11 @@ name: Yarn description: Sets up the Yarn, the Yarn Cache, and installs +inputs: + cachix-auth-token: + required: true + description: "Your Cachix auth token." + runs: using: composite steps: @@ -10,7 +15,7 @@ runs: uses: cachix/cachix-action@v10 with: name: saber - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + authToken: ${{ inputs.cachix-auth-token }} # Install Node - uses: actions/setup-node@v3 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 664a9a347..28cb8b344 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,31 +16,27 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/actions/yarn + with: + cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} - run: yarn build - run: yarn size typecheck: runs-on: ubuntu-latest + needs: build steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/yarn - - run: yarn build - run: yarn typecheck test: runs-on: ubuntu-latest + needs: build steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/yarn - - run: yarn build - run: yarn test lint: runs-on: ubuntu-latest + needs: build steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/yarn - - run: yarn build - run: yarn lint:ci doctor: @@ -48,6 +44,8 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/actions/yarn + with: + cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} # workaround b/c it's broken - run: yarn plugin remove @yarnpkg/plugin-version - run: yarn doctor packages/ From efa137ef943b1478cc78e48ee4e5c6a57d560bd7 Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:35:24 -0500 Subject: [PATCH 4/7] set shell --- .github/actions/yarn/action.yml | 2 ++ .github/workflows/main.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/yarn/action.yml b/.github/actions/yarn/action.yml index 6d339f220..ee50ad6da 100644 --- a/.github/actions/yarn/action.yml +++ b/.github/actions/yarn/action.yml @@ -22,6 +22,7 @@ runs: - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + shell: nix shell .#ci --command bash {0} - name: Yarn Cache uses: actions/cache@v3 with: @@ -30,3 +31,4 @@ runs: restore-keys: | ${{ runner.os }}-modules- - run: yarn install + shell: nix shell .#ci --command bash {0} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28cb8b344..ec4a447c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ on: defaults: run: - shell: nix shell .#env-anchor-idls --command bash {0} + shell: nix shell .#ci --command bash {0} jobs: build: From 768ffa59dceeff2982ff544f582ba2fd16e59a11 Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:35:48 -0500 Subject: [PATCH 5/7] add bash --- flake.nix | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 9e74b83b1..3f932ad89 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,7 @@ rec { packages.ci = pkgs.buildEnv { name = "ci"; - paths = with pkgs; [ nodejs yarn nixpkgs-fmt ]; + paths = with pkgs; [ nodejs yarn nixpkgs-fmt bash ]; }; devShell = pkgs.mkShell { buildInputs = [ packages.ci ]; }; }); diff --git a/yarn.lock b/yarn.lock index 1989f9d2d..ceea20011 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3238,7 +3238,7 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:^18.0.10": +"@types/react@npm:^18.0.10, @types/react@npm:^18.0.9": version: 18.0.10 resolution: "@types/react@npm:18.0.10" dependencies: From 172ace73dd88a6b6b0331739ac6865b0d913b4de Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:48:46 -0500 Subject: [PATCH 6/7] fix workflow --- .github/workflows/main.yml | 17 ++++++++++++++--- package.json | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec4a447c6..b6a19bf07 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,20 +23,31 @@ jobs: typecheck: runs-on: ubuntu-latest - needs: build steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/yarn + with: + cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} + - run: yarn build - run: yarn typecheck test: runs-on: ubuntu-latest - needs: build steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/yarn + with: + cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} + - run: yarn build - run: yarn test lint: runs-on: ubuntu-latest - needs: build steps: + - uses: ./.github/actions/yarn + with: + cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} + - run: yarn build - run: yarn lint:ci doctor: diff --git a/package.json b/package.json index 1735d9297..8db39ba92 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ ], "lint-staged": { "*.nix": "nixpkgs-fmt", - "*.{ts,tsx}": "eslint --cache --fix", - "*.{md,js,json,yml,yaml,css,md}": "prettier --write" + "*.{ts,tsx,mts,cts}": "eslint --cache --fix", + "*.{md,js,jsx,json,yml,yaml,css,md}": "prettier --write" }, "devDependencies": { "@babel/core": "^7.18.2", From 1ff033ff0385640983bb6fd88eccff961e5a1c94 Mon Sep 17 00:00:00 2001 From: Ian Macalinao Date: Wed, 1 Jun 2022 12:49:51 -0500 Subject: [PATCH 7/7] missing checkout --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b6a19bf07..7e0958027 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,7 @@ jobs: lint: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 - uses: ./.github/actions/yarn with: cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}