From 3f7727d6cefee0bb2e2307cf6e06276c8be3c851 Mon Sep 17 00:00:00 2001 From: Mike North Date: Sun, 4 May 2025 16:04:59 -0700 Subject: [PATCH 1/3] update CI workflow name --- .github/workflows/ci-website.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-website.yml b/.github/workflows/ci-website.yml index 429c4f7db..59c87026b 100644 --- a/.github/workflows/ci-website.yml +++ b/.github/workflows/ci-website.yml @@ -1,4 +1,4 @@ -name: Website +name: Website Build on: pull_request: @@ -46,8 +46,8 @@ jobs: strategy: matrix: os: - # - macos-latest - - windows-latest + # - macos-latest + - windows-latest steps: - uses: actions/checkout@v4 - uses: volta-cli/action@v4 @@ -103,7 +103,6 @@ jobs: experimental: true name: 'ts-canary' - steps: - uses: actions/checkout@v4 - uses: volta-cli/action@v4 @@ -112,7 +111,7 @@ jobs: run: yarn workspaces foreach --exclude hello-ts --exclude '@mike-north/typescript-courses' -vpi add -D typescript@${{ matrix.typescript-version}} - name: Build run: yarn build - - name: Type-check website + - name: Type-check website run: yarn postinstall && yarn typecheck - name: Test run: yarn test @@ -130,7 +129,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish: - needs: [build, os-compatibility, node-compatibility, ts-compatibility] + needs: + [build, os-compatibility, node-compatibility, ts-compatibility] runs-on: ubuntu-latest if: success() && github.ref == 'refs/heads/main' steps: @@ -144,4 +144,3 @@ jobs: github_token: ${{ secrets.ACCESS_TOKEN }} publish_dir: ./packages/website/public cname: www.typescript-training.com - From 6e093479a343ec31e0ea3cc200b50fee603a948e Mon Sep 17 00:00:00 2001 From: Mike North Date: Sun, 4 May 2025 16:13:05 -0700 Subject: [PATCH 2/3] Cypress cache key uses proper parameter name --- .github/workflows/ci-website.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-website.yml b/.github/workflows/ci-website.yml index 59c87026b..08a4d36a3 100644 --- a/.github/workflows/ci-website.yml +++ b/.github/workflows/ci-website.yml @@ -33,11 +33,11 @@ jobs: with: working-directory: packages/website start: yarn test-cypress - key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} install-command: yarn install browser: chrome wait-on: 'http://localhost:8000' wait-on-timeout: 120 + cache-key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} os-compatibility: @@ -81,7 +81,7 @@ jobs: with: working-directory: packages/website start: yarn test-cypress - key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} + cache-key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} install-command: yarn install browser: chrome wait-on: 'http://localhost:8000' @@ -120,7 +120,7 @@ jobs: with: working-directory: packages/website start: yarn test-cypress - key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} + cache-key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} install-command: yarn install browser: chrome wait-on: 'http://localhost:8000' From 508b51cb0b0ca531413cbb94fb1396cf0bc5f214 Mon Sep 17 00:00:00 2001 From: Mike North Date: Sun, 4 May 2025 16:31:09 -0700 Subject: [PATCH 3/3] add gha caching --- .github/workflows/ci-website.yml | 182 +++++++++++++++++++++++-------- 1 file changed, 138 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci-website.yml b/.github/workflows/ci-website.yml index 08a4d36a3..1d6edf86c 100644 --- a/.github/workflows/ci-website.yml +++ b/.github/workflows/ci-website.yml @@ -15,19 +15,57 @@ on: - '.github/**' - 'package.json' - 'yarn.lock' + jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: volta-cli/action@v4 + + # Add yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-yarn- + ${{ runner.os }}-node-${{ matrix.node-version }}- + ${{ runner.os }}- + + # Add build cache + - name: Cache build output + uses: actions/cache@v3 + with: + path: | + **/dist + **/build + **/.cache + **/public + key: ${{ runner.os }}-node-${{ matrix.node-version }}-build-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-build- + ${{ runner.os }}-node-${{ matrix.node-version }}- + ${{ runner.os }}- + - run: yarn + - name: Build run: yarn build + - name: Lint run: yarn lint + - name: Test run: yarn test + - name: Cypress uses: cypress-io/github-action@v6 with: @@ -37,40 +75,40 @@ jobs: browser: chrome wait-on: 'http://localhost:8000' wait-on-timeout: 120 - cache-key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} + cache-key: cypress-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - os-compatibility: - needs: build - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - # - macos-latest - - windows-latest - steps: - - uses: actions/checkout@v4 - - uses: volta-cli/action@v4 - - run: yarn - - name: Build - run: yarn build - - name: Test - run: yarn test node-compatibility: needs: build runs-on: ubuntu-latest - strategy: + fail-fast: false matrix: - node-version: [20] - # node-version: [16.x, 18.x, 20.x] + node-version: [16.x, 18.x, 20.x] steps: - uses: actions/checkout@v4 - uses: volta-cli/action@v4 with: node-version: ${{ matrix.node-version }} yarn-version: 3.6.4 + + # Add yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-yarn- + ${{ runner.os }}-node-${{ matrix.node-version }}- + ${{ runner.os }}- + - run: yarn - name: Build run: yarn build @@ -81,19 +119,56 @@ jobs: with: working-directory: packages/website start: yarn test-cypress - cache-key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} install-command: yarn install browser: chrome wait-on: 'http://localhost:8000' wait-on-timeout: 120 + cache-key: cypress-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + os-compatibility: + needs: build + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + node-version: 20 + - os: ubuntu-latest + node-version: 20 + steps: + - uses: actions/checkout@v4 + - uses: volta-cli/action@v4 + with: + node-version: ${{ matrix.node-version }} + yarn-version: 3.6.4 + + # Add yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn- + ${{ matrix.os }}-node-${{ matrix.node-version }}- + ${{ matrix.os }}- + ts-compatibility: needs: build runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} strategy: + fail-fast: false matrix: + node-version: [20.x] typescript-version: [beta, next] include: - typescript-version: beta @@ -102,43 +177,62 @@ jobs: - typescript-version: next experimental: true name: 'ts-canary' - steps: - uses: actions/checkout@v4 - uses: volta-cli/action@v4 - - run: yarn - - name: Installing TypeScript ${{ matrix.typescript-version }} - run: yarn workspaces foreach --exclude hello-ts --exclude '@mike-north/typescript-courses' -vpi add -D typescript@${{ matrix.typescript-version}} - - name: Build - run: yarn build - - name: Type-check website - run: yarn postinstall && yarn typecheck - - name: Test - run: yarn test - - name: Cypress - uses: cypress-io/github-action@v6 with: - working-directory: packages/website - start: yarn test-cypress - cache-key: cypress-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} - install-command: yarn install - browser: chrome - wait-on: 'http://localhost:8000' - wait-on-timeout: 120 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + node-version: ${{ matrix.node-version }} + yarn-version: 3.6.4 + + # Add yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-node-${{ matrix.node-version }}-ts-${{ matrix.typescript-version }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node-version }}-ts-${{ matrix.typescript-version }}-yarn- + ${{ runner.os }}-node-${{ matrix.node-version }}-ts-${{ matrix.typescript-version }}- + ${{ runner.os }}-node-${{ matrix.node-version }}- + ${{ runner.os }}- publish: - needs: - [build, os-compatibility, node-compatibility, ts-compatibility] + needs: [build, os-compatibility, node-compatibility, ts-compatibility] runs-on: ubuntu-latest if: success() && github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - uses: volta-cli/action@v4 + with: + node-version: 20.x + yarn-version: 3.6.4 + + # Add yarn cache + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-node-20-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-20-yarn- + ${{ runner.os }}-node-20- + ${{ runner.os }}- + - run: yarn + - name: Build run: yarn workspace website run build-prod + - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.ACCESS_TOKEN }}