Skip to content

Commit

Permalink
build: use nix in CI (#616)
Browse files Browse the repository at this point in the history
* build: use nix in CI

* no shell

* dependencies

* set shell

* add bash

* fix workflow

* missing checkout
  • Loading branch information
macalinao committed Jun 1, 2022
1 parent c1b391d commit 7b3c329
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
22 changes: 17 additions & 5 deletions .github/actions/yarn/action.yml
@@ -1,22 +1,34 @@
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:
- 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: ${{ inputs.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
shell: nix shell .#ci --command bash {0}
- 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') }}
restore-keys: |
${{ runner.os }}-modules-
- run: yarn install
shell: bash
shell: nix shell .#ci --command bash {0}
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -6,12 +6,18 @@ on:
pull_request:
branches: [master]

defaults:
run:
shell: nix shell .#ci --command bash {0}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/yarn
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: yarn build
- run: yarn size

Expand All @@ -20,6 +26,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/yarn
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: yarn build
- run: yarn typecheck

Expand All @@ -28,6 +36,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/yarn
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: yarn build
- run: yarn test

Expand All @@ -36,6 +46,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/yarn
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: yarn build
- run: yarn lint:ci

Expand All @@ -44,6 +56,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/
2 changes: 1 addition & 1 deletion flake.nix
Expand Up @@ -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 ]; };
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 7b3c329

Please sign in to comment.