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

wip: separate into runner, config, and plugins #283

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
2 changes: 1 addition & 1 deletion .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
/* This file is automatically updated by @npmcli/template-oss. Do not edit. */

module.exports = {
extends: ['@commitlint/config-conventional'],
Expand Down
11 changes: 3 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This file is automatically added by @npmcli/template-oss. Do not edit. */
/* This file is automatically updated by @npmcli/template-oss. Do not edit. */

'use strict'

Expand All @@ -10,11 +10,6 @@ const localConfigs = readdir(__dirname)

module.exports = {
root: true,
ignorePatterns: [
'workspace/test-workspace/**',
],
extends: [
'@npmcli',
...localConfigs,
],
ignorePatterns: ['workspaces/**'],
extends: ['@npmcli', ...localConfigs],
}
6 changes: 0 additions & 6 deletions .eslintrc.local.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.
# This file is automatically updated by @npmcli/template-oss. Do not edit.

* @npm/cli-team
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Bug
description: File a bug/issue
title: "[BUG] <title>"
labels: [ Bug, Needs Triage ]
labels: [Bug, Needs Triage]

body:
- type: checkboxes
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.
# This file is automatically updated by @npmcli/template-oss. Do not edit.

blank_issues_enabled: true
23 changes: 23 additions & 0 deletions .github/actions/audit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Audit

runs:
using: composite
steps:
- name: Run Full Audit
shell: bash
run: |
if ! npm audit; then
COUNT=$(npm audit --audit-level=none --json | jq -r '.metadata.vulnerabilities.total')
echo "::warning title=All Vulnerabilities::Found $COUNT"
fi

- name: Run Production Audit
shell: bash
run: |
if ! npm audit --omit=dev; then
COUNT=$(npm audit --omit=dev --audit-level=none --json | jq -r '.metadata.vulnerabilities.total')
echo "::error title=Production Vulnerabilities::Found $COUNT"
exit 1
fi
39 changes: 39 additions & 0 deletions .github/actions/changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Get Changed Files

inputs:
token:
description: GitHub token to use
required: true

outputs:
names:
value: ${{ steps.files.outputs.result }}

runs:
using: composite
steps:
- name: Get Changed Files
uses: actions/github-script@v6
id: files
with:
github-token: ${{ inputs.token }}
script: |
const { repo: { owner, repo }, eventName, payload, sha } = context
let files
if (eventName === 'pull_request' || eventName === 'pull_request_target') {
files = await github.paginate(github.rest.pulls.listFiles, {
owner,
repo,
pull_number: payload.pull_request.number,
})
} else {
const { data: commit } = await github.rest.repos.getCommit({
owner,
repo,
ref: sha,
})
files = commit.files
}
return files.map(f => f.filename)
30 changes: 30 additions & 0 deletions .github/actions/changed-workspaces/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Get Changed Workspaces

inputs:
token:
description: GitHub token to use
files:
description: json stringified array of file names or --all

outputs:
flags:
value: ${{ steps.workspaces.outputs.flags }}

runs:
using: composite
steps:
- name: Get Changed Files
uses: ./.github/actions/changed-files
if: ${{ !inputs.files }}
id: files
with:
token: ${{ inputs.token }}

- name: Get Workspaces
shell: bash
id: workspaces
uses: ./.github/actions/get-workspaces
with:
files: ${{ inputs.files || steps.files.outputs.names }}
25 changes: 25 additions & 0 deletions .github/actions/conclude-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Conclude Check
description: Conclude a check

inputs:
token:
description: GitHub token to use
required: true
conclusion:
description: conclusion of check
require: true
check-id:
description: id of check to conclude
required: true

runs:
using: composite
steps:
- name: Conclude Check
uses: LouisBrunner/[email protected]
with:
token: ${{ inputs.token }}
conclusion: ${{ inputs.conclusion }}
check_id: ${{ inputs.check-id }}
69 changes: 69 additions & 0 deletions .github/actions/create-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Create Check
description: Create a check and associate it with a sha

inputs:
token:
description: GitHub token to use
required: true
sha:
description: sha to attach the check to
required: true
job-name:
description: Name of the job to find
required: true
job-status:
description: Status of the check being created
default: "in_progress"

outputs:
check-id:
description: The ID of the check that was created
value: ${{ steps.check.outputs.check_id }}

runs:
using: composite
steps:
- name: Get Workflow Job
uses: actions/github-script@v6
id: workflow-job
env:
JOB_NAME: ${{ inputs.job-name }}
with:
github-token: ${{ inputs.token }}
script: |
const { JOB_NAME } = process.env
const { repo: { owner, repo }, runId, serverUrl } = context

const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRun, {
owner,
repo,
run_id: runId,
}).then(jobs => jobs.map(j => ({ name: j.name, html_url: j.html_url })))

console.log(`found jobs: ${JSON.stringify(jobs, null, 2)}`)

const job = jobs.find(j => j.name.endsWith(JOB_NAME))

console.log(`found job: ${JSON.stringify(job, null, 2)}`)

const shaUrl = `${serverUrl}/${owner}/${repo}/commit/${{ inputs.sha }}`
const summary = `This check is assosciated with ${shaUrl}\n\n`
const message = job?.html_url
? `For run logs, click here: ${job.html_url}`
: `Run logs could not be found for a job with name: "${JOB_NAME}"`

// Return a json object with properties that LouisBrunner/checks-actions
// expects as the output of the check
return { summary: summary + message }

- name: Create Check
uses: LouisBrunner/[email protected]
id: check
with:
token: ${{ inputs.token }}
status: ${{ inputs.job-status }}
name: ${{ inputs.job-name }}
sha: ${{ inputs.sha }}
output: ${{ steps.workflow-job.outputs.result }}
22 changes: 22 additions & 0 deletions .github/actions/deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Dependencies

inputs:
command:
description: command to run for the dependencies step
default: "install --ignore-scripts --no-audit --no-fund"
flags:
description: extra flags to pass to the dependencies step
default: ""
shell:
description: shell to run on
default: "bash"

runs:
using: composite
steps:
- name: Install Dependencies
shell: ${{ inputs.shell }}
run: |
npm ${{ inputs.command }} ${{ inputs.flags }}
15 changes: 15 additions & 0 deletions .github/actions/get-workspaces/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: "Get Workspaces"

inputs:
files:
description: "files"

outputs:
flags:
description: "workspace flags"

runs:
using: "node16"
main: "index.js"
14 changes: 14 additions & 0 deletions .github/actions/get-workspaces/index.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: Lint

inputs:
flags:
description: flags to pass to the commands
default: ""

runs:
using: composite
steps:
- name: Lint
shell: bash
run: |
npm run lint --ignore-scripts ${{ inputs.flags }}
- name: Post Lint
shell: bash
run: |
npm run postlint --ignore-scripts ${{ inputs.flags }}
14 changes: 14 additions & 0 deletions .github/actions/release-manager/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically updated by @npmcli/template-oss. Do not edit.

name: "Release Manager"

inputs:
token:
required: true
pr-number:
required: true
comment-id:

runs:
using: "node16"
main: "index.js"
Loading