diff --git a/.github/workflows/main.pr.yml b/.github/workflows/main.pr.yml index 3aed35f9..c1ca5515 100644 --- a/.github/workflows/main.pr.yml +++ b/.github/workflows/main.pr.yml @@ -13,25 +13,25 @@ jobs: lint-pull-request: name: Lint runs-on: ubuntu-22.04 - strategy: - fail-fast: true - matrix: - node: [20.x] steps: - - name: Setup node v${{ matrix.node }} + - name: Setup node v20.x uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node }} + node-version: 20.x - name: Checkout uses: actions/checkout@v4 with: persist-credentials: false + - name: Construct cache keys + run: | + echo node_modules_key='["${{ runner.os }}", "node_modules", "20.x", "${{ hashFiles('package.json', 'yarn.lock') }}"]' >> $GITHUB_ENV; + - name: Cache node_modules uses: actions/cache@v4 with: - key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json', 'yarn.lock') }} + key: ${{ join(fromJSON(env.node_modules_key), '-') }} path: node_modules - name: Check if source or test files changed @@ -51,14 +51,14 @@ jobs: build-and-test-pull-request: needs: - lint-pull-request - name: Test + name: Test ${{ matrix.node }} ${{ join(fromJSON('["${{ matrix.target }}", "${{ matrix.module }}"]'), '/') }} runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: node: [16.x, 18.x, 20.x] - module: [cjs, esm, umd] target: [es5, es2015, esnext] + module: [cjs, esm, umd] include: - {node: 16.x, target: ix} - {node: 18.x, target: ix} @@ -69,21 +69,27 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + - name: Checkout uses: actions/checkout@v4 with: persist-credentials: false + - name: Construct cache keys + run: | + echo node_modules_key='["${{ runner.os }}", "node_modules", "${{ matrix.node }}", "${{ hashFiles('package.json', 'yarn.lock') }}"]' >> $GITHUB_ENV; + echo targets_key='["${{ runner.os }}", "targets", "${{ matrix.node }}", "${{ matrix.target }}", "${{ matrix.module }}", "${{ hashFiles('package.json', 'yarn.lock', 'tsconfig.json', 'src/**/*', 'tsconfigs/**/*') }}"]' >> $GITHUB_ENV; + - name: Cache targets uses: actions/cache@v4 with: - key: ${{ runner.os }}-targets-${{ matrix.node }}-${{ matrix.target }}-${{ matrix.module }}-${{ hashFiles('package.json', 'yarn.lock', 'src/**/*') }} + key: ${{ join(fromJSON(env.targets_key), '-') }} path: targets - name: Cache node_modules uses: actions/cache@v4 with: - key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json', 'yarn.lock') }} + key: ${{ join(fromJSON(env.node_modules_key), '-') }} path: node_modules - name: Check if test files changed @@ -92,6 +98,10 @@ jobs: with: files: | spec/**/* + tsconfig.json + tsconfigs/**/* + jest.config.js + jestconfigs/**/* - name: Check if source files changed id: source_files_changed @@ -101,7 +111,10 @@ jobs: .npmrc yarn.lock package.json + tsconfig.json src/**/* + gulp/**/* + tsconfigs/**/* integration/**/* - name: Install dependencies @@ -158,18 +171,18 @@ jobs: test-tree-shaking-pull-request: needs: - build-and-test-pull-request - name: Integration + name: Bundle ${{ matrix.bundler }} ${{ matrix.target }} ${{ matrix.module }} runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - module: [cjs, esm, umd] - target: [es5, es2015, esnext] bundler: [esbuild, rollup, webpack] + target: [es5, es2015, esnext] + module: [cjs, esm, umd] include: - - {target: ix, bundler: esbuild} - - {target: ix, bundler: rollup} - - {target: ix, bundler: webpack} + - {bundler: esbuild, target: ix} + - {bundler: rollup, target: ix} + - {bundler: webpack, target: ix} steps: - name: Setup node v20.x uses: actions/setup-node@v4 @@ -180,31 +193,24 @@ jobs: with: persist-credentials: false + - name: Construct cache keys + run: | + echo node_modules_key='["${{ runner.os }}", "node_modules", "20.x", "${{ hashFiles('package.json', 'yarn.lock') }}"]' >> $GITHUB_ENV; + echo targets_key='["${{ runner.os }}", "targets", "20.x", "${{ matrix.target }}", "${{ matrix.module }}", "${{ hashFiles('package.json', 'yarn.lock', 'tsconfig.json', 'src/**/*', 'tsconfigs/**/*') }}"]' >> $GITHUB_ENV; + - name: Cache targets uses: actions/cache@v4 with: - key: ${{ runner.os }}-targets-20.x-ix--${{ hashFiles('package.json', 'yarn.lock', 'src/**/*') }} + key: ${{ join(fromJSON(env.targets_key), '-') }} path: targets - name: Cache node_modules uses: actions/cache@v4 with: - key: ${{ runner.os }}-node_modules-20.x-${{ hashFiles('package.json', 'yarn.lock') }} + key: ${{ join(fromJSON(env.node_modules_key), '-') }} path: node_modules - - name: Check if source files changed - id: source_files_changed - uses: tj-actions/changed-files@v44 - with: - files: | - .npmrc - yarn.lock - package.json - src/**/* - integration/**/* - - name: Test ${{ matrix.bundler }} tree-shaking - if: ${{ steps.source_files_changed.outputs.any_modified == 'true' }} env: t: "${{ matrix.target }}" m: "${{ matrix.module }}"