|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +jobs: |
| 11 | + install: |
| 12 | + name: Install node_modules |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v3 |
| 18 | + |
| 19 | + - name: Set up Node |
| 20 | + uses: actions/setup-node@v3 |
| 21 | + with: |
| 22 | + node-version-file: .nvmrc |
| 23 | + |
| 24 | + - name: Get yarn cache directory path |
| 25 | + id: yarn-cache-dir-path |
| 26 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 27 | + |
| 28 | + - name: Cache node_modules |
| 29 | + - uses: actions/cache@v3 |
| 30 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 31 | + with: |
| 32 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 33 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 34 | + restore-keys: | |
| 35 | + ${{ runner.os }}-yarn- |
| 36 | +
|
| 37 | + - name: Install Dependencies |
| 38 | + if: steps.yarn-cache.outputs.cache-hit != 'true' |
| 39 | + run: yarn --prefer-offline --frozen-lockfile |
| 40 | + |
| 41 | + lint: |
| 42 | + name: Lint |
| 43 | + needs: install |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Checkout repository |
| 48 | + uses: actions/checkout@v3 |
| 49 | + |
| 50 | + - name: Set up Node |
| 51 | + uses: actions/setup-node@v3 |
| 52 | + with: |
| 53 | + node-version-file: .nvmrc |
| 54 | + |
| 55 | + - name: Cache node_modules |
| 56 | + - uses: actions/cache@v3 |
| 57 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 58 | + with: |
| 59 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 60 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 61 | + restore-keys: | |
| 62 | + ${{ runner.os }}-yarn- |
| 63 | +
|
| 64 | + - name: Install Dependencies |
| 65 | + if: steps.yarn-cache.outputs.cache-hit != 'true' |
| 66 | + run: yarn --prefer-offline --frozen-lockfile |
| 67 | + |
| 68 | + - name: Lint |
| 69 | + run: yarn lint |
| 70 | + |
| 71 | + build: |
| 72 | + name: Build |
| 73 | + needs: install |
| 74 | + runs-on: ubuntu-latest |
| 75 | + |
| 76 | + steps: |
| 77 | + - name: Checkout repository |
| 78 | + uses: actions/checkout@v3 |
| 79 | + |
| 80 | + - name: Set up Node |
| 81 | + uses: actions/setup-node@v3 |
| 82 | + with: |
| 83 | + node-version-file: .nvmrc |
| 84 | + |
| 85 | + - name: Cache node_modules |
| 86 | + - uses: actions/cache@v3 |
| 87 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 88 | + with: |
| 89 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 90 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 91 | + restore-keys: | |
| 92 | + ${{ runner.os }}-yarn- |
| 93 | +
|
| 94 | + - name: Install Dependencies |
| 95 | + if: steps.yarn-cache.outputs.cache-hit != 'true' |
| 96 | + run: yarn --prefer-offline --frozen-lockfile |
| 97 | + |
| 98 | + - name: Built |
| 99 | + run: yarn build |
| 100 | + |
| 101 | + test: |
| 102 | + name: Test (${{ matrix.shard }}) |
| 103 | + needs: install |
| 104 | + runs-on: ubuntu-latest |
| 105 | + strategy: |
| 106 | + fail-fast: false |
| 107 | + matrix: |
| 108 | + shard: ["1/2", "2/2"] |
| 109 | + |
| 110 | + steps: |
| 111 | + - name: Checkout repository |
| 112 | + uses: actions/checkout@v3 |
| 113 | + |
| 114 | + - name: Set up Node |
| 115 | + uses: actions/setup-node@v3 |
| 116 | + with: |
| 117 | + node-version-file: .nvmrc |
| 118 | + |
| 119 | + - name: Cache node_modules |
| 120 | + - uses: actions/cache@v3 |
| 121 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 122 | + with: |
| 123 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 124 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 125 | + restore-keys: | |
| 126 | + ${{ runner.os }}-yarn- |
| 127 | +
|
| 128 | + - name: Install Dependencies |
| 129 | + if: steps.yarn-cache.outputs.cache-hit != 'true' |
| 130 | + run: yarn --prefer-offline --frozen-lockfile |
| 131 | + |
| 132 | + - name: Test |
| 133 | + run: yarn test -- --maxWorkers 2 --shard ${{ matrix.shard }} |
0 commit comments