diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index c7089ff63b..a0c5bdb080 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -2,27 +2,12 @@ name: Benchmarks on: workflow_dispatch: - pull_request: - branches: - - '**' - paths: - - '**/src/**.js' - push: - branches: - - main - - v11 - paths: - - '**/src/**.js' + workflow_call: jobs: - build_test: - name: Build & Test - uses: ./.github/workflows/ci.yml - prepare: name: Prepare environment runs-on: ubuntu-latest - needs: build_test timeout-minutes: 5 steps: - name: Download locally built preact package @@ -34,7 +19,7 @@ jobs: uses: andrewiggins/download-base-artifact@v3 with: artifact: npm-package - workflow: ci.yml + workflow: build-test.yml required: false - run: mv preact.tgz preact-main.tgz - name: Upload locally build & base preact package diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000000..98604af796 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,55 @@ +name: Build & Test + +on: + workflow_dispatch: + workflow_call: + inputs: + ref: + description: 'Branch or tag ref to check out' + type: string + required: false + default: '' + artifact_name: + description: 'Name of the artifact to upload' + type: string + required: false + default: 'npm-package' + +jobs: + build_test: + name: Build & Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || '' }} + - uses: actions/setup-node@v4 + with: + node-version-file: 'package.json' + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + - run: npm ci + - name: test + env: + CI: true + COVERAGE: true + FLAKEY: false + # Not using `npm test` since it rebuilds source which npm ci has already done + run: | + npm run lint + npm run test:unit + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v2.3.0 + timeout-minutes: 2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Package + # Use --ignore-scripts here to avoid re-building again before pack + run: | + npm pack --ignore-scripts + mv preact-*.tgz preact.tgz + - name: Upload npm package + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_name || 'npm-package' }} + path: preact.tgz \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ca16caf6b..b093268386 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,18 +2,6 @@ name: CI on: workflow_dispatch: - workflow_call: - inputs: - ref: - description: 'Branch or tag ref to check out' - type: string - required: false - default: '' - artifact_name: - description: 'Name of the artifact to upload' - type: string - required: false - default: 'npm-package' pull_request: branches: - '**' @@ -21,42 +9,34 @@ on: branches: - main - restructure + - v11 jobs: - build_test: - name: Build & Test + filter_jobs: + name: Filter jobs runs-on: ubuntu-latest + outputs: + jsChanged: ${{ steps.filter.outputs.jsChanged }} steps: - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.ref || '' }} - - uses: actions/setup-node@v4 - with: - node-version-file: 'package.json' - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - - run: npm ci - - name: test - env: - CI: true - COVERAGE: true - FLAKEY: false - # Not using `npm test` since it rebuilds source which npm ci has already done - run: | - npm run lint - npm run test:unit - - name: Coveralls GitHub Action - uses: coverallsapp/github-action@v2.3.0 - timeout-minutes: 2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Package - # Use --ignore-scripts here to avoid re-building again before pack - run: | - npm pack --ignore-scripts - mv preact-*.tgz preact.tgz - - name: Upload npm package - uses: actions/upload-artifact@v4 + - uses: dorny/paths-filter@v3 + id: filter with: - name: ${{ inputs.artifact_name || 'npm-package' }} - path: preact.tgz \ No newline at end of file + filters: | + jsChanged: '**/src/**.js' + + compressed_size: + name: Compressed Size + needs: filter_jobs + if: ${{ needs.filter_jobs.outputs.jsChanged == 'true' }} + uses: ./.github/workflows/size.yml + + build_test: + name: Build & Test + needs: filter_jobs + uses: ./.github/workflows/build-test.yml + + benchmarks: + name: Benchmarks + needs: build_test + if: ${{ needs.filter_jobs.outputs.jsChanged == 'true' }} + uses: ./.github/workflows/benchmarks.yml \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bad394259..7c7af10801 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ on: create jobs: build: if: github.ref_type == 'tag' - uses: preactjs/preact/.github/workflows/ci.yml@main + uses: preactjs/preact/.github/workflows/build-test.yml@main release: runs-on: ubuntu-latest diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml index ee60e77670..0dff893cb0 100644 --- a/.github/workflows/size.yml +++ b/.github/workflows/size.yml @@ -1,11 +1,7 @@ name: Compressed Size on: - pull_request: - branches: - - '**' - paths: - - '**/src/**.js' + workflow_call: jobs: build: @@ -22,4 +18,4 @@ jobs: repo-token: '${{ secrets.GITHUB_TOKEN }}' # Our `prepare` script already builds the app post-install, # building it again would be redundant - build-script: 'npm run --if-present noop' + build-script: 'npm run --if-present noop' \ No newline at end of file