Skip to content

Commit

Permalink
build: update actions file
Browse files Browse the repository at this point in the history
Reformat actions to maintain readability and consistency
between different actions.
Update some used actions (e.g. `actions/upload-artifact`).
Rename misc action.
Add more (complete) `path-ignores`.
Use GitHub CLI when possible.
  • Loading branch information
Mesteery committed Aug 25, 2021
1 parent 95834d1 commit 74d8e7e
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 159 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/authors.yml
@@ -1,22 +1,28 @@
name: "authors update"
on:
workflow_dispatch:
name: authors update
on: workflow_dispatch

jobs:
authors_update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0' # this is required to actually get all the authors
- run: "tools/update-authors.js" # run the AUTHORS tool
fetch-depth: 0 # this is required to actually get all the authors
- run: tools/update-authors.js # run the AUTHORS tool
- uses: gr2m/create-or-update-pull-request-action@v1 # create a PR or update the Action's existing PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: "meta: update AUTHORS"
body: "If this PR exists, there's presumably new additions to the AUTHORS file. This is an automatically generated PR by the `authors.yml` GitHub Action, which runs `tools/update-authors.js` and submits a new PR or updates an existing PR.\n\nPlease note that there might be duplicate entries. If there are, please remove them and add the duplicate emails to .mailmap directly to this PR."
branch: "actions/authors-update" # custom branch *just* for this Action.
commit-message: "meta: update AUTHORS"
title: 'meta: update AUTHORS'
commit-message: 'meta: update AUTHORS'
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
body: >
If this PR exists, there's presumably new additions to the AUTHORS file.
This is an automatically generated PR by the `authors.yml` GitHub Action,
which runs `tools/update-authors.js` and submits a new PR or updates an existing PR.
Please note that there might be duplicate entries. If there are, please remove them and
add the duplicate emails to .mailmap directly to this PR.
branch: actions/authors-update # custom branch *just* for this Action.
labels: meta
35 changes: 9 additions & 26 deletions .github/workflows/auto-start-ci.yml
@@ -1,4 +1,3 @@
---
name: Auto Start CI

on:
Expand All @@ -7,23 +6,23 @@ on:
# optimistic, it can take longer to run.
# To understand why `schedule` is used instead of other events, refer to
# ./doc/guides/commit-queue.md
- cron: "*/5 * * * *"
- cron: '*/5 * * * *'

env:
NODE_VERSION: lts/*

jobs:
startCI:
start-ci:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Install dependencies
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install node-core-utils
run: npm install -g node-core-utils

Expand All @@ -32,26 +31,6 @@ jobs:
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
# Get Pull Requests
- name: Get Pull Requests
uses: octokit/graphql-action@v2.x
id: get_prs_for_ci
with:
query: |
query prs($owner:String!, $repo:String!) {
repository(owner:$owner, name:$repo) {
pullRequests(labels: ["request-ci"], states: OPEN, last: 100) {
nodes {
number
}
}
}
}
owner: ${{ env.OWNER }}
repo: ${{ env.REPOSITORY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup node-core-utils
run: |
ncu-config set username ${{ secrets.JENKINS_USER }}
Expand All @@ -60,5 +39,9 @@ jobs:
ncu-config set owner ${{ env.OWNER }}
ncu-config set repo ${{ env.REPOSITORY }}
- name: Start CI
run: ./tools/actions/start-ci.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.OWNER }} ${{ env.REPOSITORY }} $(echo '${{ steps.get_prs_for_ci.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]')
- name: Get Pull Requests and start CI
run: |
prs=`gh pr list --repo ${{ github.repository }} --limit 100 --json number -q 'map(.number) | .[]'`
./tools/actions/start-ci.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.OWNER }} ${{ env.REPOSITORY }} $prs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 5 additions & 11 deletions .github/workflows/build-tarball.yml
Expand Up @@ -4,20 +4,15 @@ on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- master
- main
- v[0-9]+.x-staging
- v[0-9]+.x
branches: [master, main, 'v[0-9]+.x-staging', 'v[0-9]+.x']

env:
FLAKY_TESTS: dontcare
PYTHON_VERSION: 3.9

jobs:
build-tarball:
if: github.event.pull_request.draft == false
env:
PYTHON_VERSION: 3.9
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -36,13 +31,11 @@ jobs:
mkdir tarballs
mv *.tar.gz tarballs
- name: Upload tarball artifact
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v2
with:
name: tarballs
path: tarballs
test-tarball-linux:
env:
PYTHON_VERSION: 3.9
needs: build-tarball
runs-on: ubuntu-latest
steps:
Expand All @@ -54,9 +47,10 @@ jobs:
- name: Environment Information
run: npx envinfo
- name: Download tarball
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2
with:
name: tarballs
path: tarballs
- name: Extract tarball
run: |
tar xzf tarballs/*.tar.gz -C $RUNNER_TEMP
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/build-windows.yml
Expand Up @@ -3,13 +3,22 @@ name: build-windows
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- '**.md'
- doc/**
- AUTHORS
- .mailmap
- .github/**
- '!.github/workflows/build-windows.yml'
push:
branches:
- master
- main
- canary
- v[0-9]+.x-staging
- v[0-9]+.x
branches: [master, main, canary, 'v[0-9]+.x-staging', 'v[0-9]+.x']
paths-ignore:
- '**.md'
- doc/**
- AUTHORS
- .mailmap
- .github/**
- '!.github/workflows/build-windows.yml'

env:
PYTHON_VERSION: 3.9
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/close-stalled.yml
@@ -1,21 +1,26 @@
name: Close stalled issues and PRs
on:
schedule:
- cron: "0 0 * * *"
- cron: 0 0 * * *

env:
CLOSE_MESSAGE: >
Closing this because it has stalled. Feel free to reopen if this issue is still relevant,
or to ping the collaborator who labelled it stalled if you have any questions.
jobs:
stale:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-close: 30
stale-pr-label: stalled
stale-issue-label: stalled
close-issue-message: Closing this because it has stalled. Feel free to reopen if this issue is still relevant, or to ping the collaborator who labelled it stalled if you have any questions.
close-pr-message: Closing this because it has stalled. Feel free to reopen if this PR is still relevant, or to ping the collaborator who labelled it stalled if you have any questions.
close-issue-message: ${{ env.CLOSE_MESSAGE }}
close-pr-message: ${{ env.CLOSE_MESSAGE }}
# used to filter issues to check whether or not should be closed, avoids hitting maximum operations allowed if needing to paginate through all open issues
only-labels: stalled
# max requests it will send per run to the GitHub API before it deliberately exits to avoid hitting API rate limits
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/comment-labeled.yml
@@ -1,29 +1,34 @@
name: Comment on issues and PRs when labelled
name: Comment on issues and PRs when labeled
on:
issues:
types: [labeled]
pull_request_target:
types: [labeled]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STALE_MESSAGE: >-
This issue/PR was marked as stalled, it will be automatically closed in 30 days.
If it should remain open, please leave a comment explaining why it should remain open.
FAST_TRACK_MESSAGE: Fast-track has been requested by @${{ github.actor }}. Please 👍 to approve.

jobs:
staleComment:
stale-comment:
if: github.repository == 'nodejs/node' && github.event.label.name == 'stalled'
runs-on: ubuntu-latest
steps:
- name: Post stalled comment
env:
COMMENTS_URL: ${{ github.event.issue.comments_url || github.event.pull_request.comments_url }}
COMMENTS_URL: ${{ github.event.issue.comments_url || github.event.pull_request.comments_url }}
run: |
curl -X POST $COMMENTS_URL \
-H "Content-Type: application/json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--data '{ "body": "This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open." }'
--data "{ \"body\": \"$STALE_MESSAGE\" }"
fastTrack:
if: github.repository == 'nodejs/node' && github.event_name == 'pull_request_target' && github.event.label.name == 'fast-track'
fast-track:
if: github.repository == 'nodejs/node' && github.event.issue.pull_request && github.event.label.name == 'fast-track'
runs-on: ubuntu-latest
steps:
- name: Request Fast-Track
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "Fast-track has been requested by @${{ github.actor }}. Please 👍 to approve."
run: gh pr comment ${{ github.event.issue.number }} --repo ${{ github.repository }} --body "$FAST_TRACK_MESSAGE"
2 changes: 1 addition & 1 deletion .github/workflows/commit-lint.yml
@@ -1,4 +1,4 @@
name: "Commit messages adheres to guidelines at https://goo.gl/p2fr5Q"
name: Commit messages adheres to guidelines at https://goo.gl/p2fr5Q

on: [pull_request]

Expand Down
35 changes: 9 additions & 26 deletions .github/workflows/commit-queue.yml
@@ -1,4 +1,3 @@
---
# This action requires the following secrets to be set on the repository:
# GH_USER_NAME: GitHub user whose Jenkins and GitHub token are defined below
# GH_USER_TOKEN: GitHub user token, to be used by ncu and to push changes
Expand All @@ -12,7 +11,7 @@ on:
# be read-only, and the Action won't have access to any other repository
# secrets, which it needs to access Jenkins API.
schedule:
- cron: "*/5 * * * *"
- cron: '*/5 * * * *'

env:
NODE_VERSION: lts/*
Expand All @@ -33,11 +32,11 @@ jobs:
# for push as well.
token: ${{ secrets.GH_USER_TOKEN }}

# Install dependencies
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install node-core-utils
run: npm install -g node-core-utils@latest

Expand All @@ -47,27 +46,6 @@ jobs:
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "DEFAULT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Get Pull Requests
uses: octokit/graphql-action@v2.x
id: get_mergable_pull_requests
with:
query: |
query release($owner:String!,$repo:String!, $base_ref:String!) {
repository(owner:$owner, name:$repo) {
pullRequests(baseRefName: $base_ref, labels: ["commit-queue"], states: OPEN, last: 100) {
nodes {
number
}
}
}
}
owner: ${{ env.OWNER }}
repo: ${{ env.REPOSITORY }}
# Commit queue is only enabled for the default branch on the repository
base_ref: ${{ env.DEFAULT_BRANCH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Configure node-core-utils
run: |
ncu-config set branch ${DEFAULT_BRANCH}
Expand All @@ -78,5 +56,10 @@ jobs:
ncu-config set repo "${REPOSITORY}"
ncu-config set owner "${OWNER}"
- name: Start the commit queue
run: ./tools/actions/commit-queue.sh ${OWNER} ${REPOSITORY} ${{ secrets.GITHUB_TOKEN }} $(echo '${{ steps.get_mergable_pull_requests.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]')
# Commit queue is only enabled for the default branch on the repository.
- name: Get Pull Requests and start the commit queue
run: |
prs=`gh pr list --repo ${{ github.repository }} --base ${{ env.DEFAULT_BRANCH }} --limit 100 --json number -q 'map(.number) | .[]'`
./tools/actions/commit-queue.sh ${OWNER} ${REPOSITORY} ${{ secrets.GITHUB_TOKEN }} $prs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 16 additions & 9 deletions .github/workflows/coverage-linux.yml
Expand Up @@ -5,18 +5,25 @@ on:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- '**.md'
- 'benchmark/**'
- 'deps/**'
- 'doc/**'
- benchmark/**
- deps/**
- doc/**,
- AUTHORS
- .mailmap
- .github/**
- '!.github/workflows/coverage-linux.yml'
push:
branches:
- master
- main
branches: [master, main]
paths-ignore:
- '**.md'
- 'benchmark/**'
- 'deps/**'
- 'doc/**'
- benchmark/**
- deps/**
- doc/**
- 'tools/**'
- AUTHORS
- .mailmap
- .github/**
- '!.github/workflows/coverage-linux.yml'

env:
PYTHON_VERSION: 3.9
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/coverage-windows.yml
Expand Up @@ -9,16 +9,22 @@ on:
- 'deps/**'
- 'doc/**'
- 'tools/**'
- AUTHORS
- .mailmap
- .github/**
- '!.github/workflows/coverage-windows.yml'
push:
branches:
- master
- main
branches: [master, main]
paths-ignore:
- '**.md'
- 'benchmark/**'
- 'deps/**'
- 'doc/**'
- 'tools/**'
- AUTHORS
- .mailmap
- .github/**
- '!.github/workflows/coverage-windows.yml'

env:
PYTHON_VERSION: 3.9
Expand Down

0 comments on commit 74d8e7e

Please sign in to comment.