Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: use separate workflows for 'push' and 'pull_request' #3491

Merged
merged 1 commit into from Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/canary.yaml
Expand Up @@ -2,7 +2,7 @@ name: Canary Release
on:
workflow_run:
workflows:
- CI
- PullRequest
types:
- completed
jobs:
Expand Down
63 changes: 1 addition & 62 deletions .github/workflows/ci.yml
@@ -1,5 +1,5 @@
name: CI
on: [push, pull_request]
on: workflow_call
jobs:
save-github-event:
name: "Save `github.event` as an artifact to use in subsequent 'workflow_run' actions"
Expand Down Expand Up @@ -183,67 +183,6 @@ jobs:
- name: Run Tests
run: npm run testonly

benchmark:
name: Run benchmark
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Deepen cloned repo
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE'

- name: Setup Node.js
uses: actions/setup-node@v2
with:
cache: npm
node-version-file: '.node-version'

- name: Install Dependencies
run: npm ci --ignore-scripts

- name: Run Benchmark
run: 'npm run benchmark -- --revs HEAD BASE'

diff-npm-package:
name: Diff content of NPM package
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Deepen cloned repo
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE'

- name: Setup Node.js
uses: actions/setup-node@v2
with:
cache: npm
node-version-file: '.node-version'

- name: Install Dependencies
run: npm ci --ignore-scripts

- name: Generate report
run: 'node resources/diff-npm-package.js BASE HEAD'

- name: Upload generated report
uses: actions/upload-artifact@v2
with:
name: npm-dist-diff.html
path: ./npm-dist-diff.html
if-no-files-found: ignore

build-npm-dist:
name: Build 'npmDist' artifact
runs-on: ubuntu-latest
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/deploy-artifact-as-branch.yml
Expand Up @@ -26,12 +26,9 @@ jobs:
- name: Remove existing files first
run: git rm -r .

- name: Download artifact into cloned branch
run: gh run download "$WORKFLOW_ID" -n "$ARTIFACT_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ID: ${{ inputs.workflow_id }}
ARTIFACT_NAME: ${{ inputs.artifact_name }}
- uses: actions/download-artifact@v2
with:
name: ${{ inputs.artifact_name }}

- name: Publish target branch
run: |
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/pull_request.yml
@@ -0,0 +1,64 @@
name: PullRequest
on: pull_request
jobs:
ci:
uses: ./.github/workflows/ci.yml

benchmark:
name: Run benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Deepen cloned repo
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE'

- name: Setup Node.js
uses: actions/setup-node@v2
with:
cache: npm
node-version-file: '.node-version'

- name: Install Dependencies
run: npm ci --ignore-scripts

- name: Run Benchmark
run: 'npm run benchmark -- --revs HEAD BASE'

diff-npm-package:
name: Diff content of NPM package
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Deepen cloned repo
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE'

- name: Setup Node.js
uses: actions/setup-node@v2
with:
cache: npm
node-version-file: '.node-version'

- name: Install Dependencies
run: npm ci --ignore-scripts

- name: Generate report
run: 'node resources/diff-npm-package.js BASE HEAD'

- name: Upload generated report
uses: actions/upload-artifact@v2
with:
name: npm-dist-diff.html
path: ./npm-dist-diff.html
if-no-files-found: ignore
23 changes: 10 additions & 13 deletions .github/workflows/cd.yml → .github/workflows/push.yml
@@ -1,29 +1,26 @@
name: CD
on:
workflow_run:
workflows:
- CI
types:
- completed
branches:
- main
name: Push
on: push
jobs:
ci:
uses: ./.github/workflows/ci.yml
deploy-to-npm-branch:
name: Deploy to `npm` branch
if: github.event.workflow_run.event == 'push'
needs: ci
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/deploy-artifact-as-branch.yml
with:
workflow_id: ${{github.event.workflow_run.id}}
workflow_id: ${{github.run_id}}
artifact_name: npmDist
target_branch: npm
commit_message: "Deploy ${{github.event.workflow_run.head_sha}} to 'npm' branch"

deploy-to-deno-branch:
name: Deploy to `deno` branch
if: github.event.workflow_run.event == 'push'
needs: ci
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/deploy-artifact-as-branch.yml
with:
workflow_id: ${{github.event.workflow_run.id}}
workflow_id: ${{github.run_id}}
artifact_name: denoDist
target_branch: deno
commit_message: "Deploy ${{github.event.workflow_run.head_sha}} to 'deno' branch"