Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Feb 13, 2023
1 parent 241dbf2 commit 76b3c6d
Show file tree
Hide file tree
Showing 86 changed files with 4,595 additions and 3,538 deletions.
17 changes: 17 additions & 0 deletions .github/actions/audit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

name: Audit

inputs:
shell:
description: shell to run on
default: bash

runs:
using: composite
steps:
- name: Run Audit
shell: ${{ inputs.shell }}
run: |
npm audit --omit=dev
npm audit --audit-level=none
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 added by @npmcli/template-oss. Do not edit.

name: Get Changed Files

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

outputs:
files:
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)
37 changes: 37 additions & 0 deletions .github/actions/changed-workspaces/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

name: Get Changed Workspaces

inputs:
token:
description: GitHub token to use
shell:
description: shell to run on
default: bash
all:
default: false
type: boolean
files:
description: json stringified array of file names
type: string

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

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

- name: Get Workspaces
shell: ${{ inputs.shell }}
id: workspaces
run: |
flags=$(npm exec --offline -- template-oss-changed-workspaces '${{ (inputs.all && '--all') || (inputs.files || steps.files.outputs.result) }}')
echo "flags=${flags}" >> $GITHUB_OUTPUT
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 added 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/checks-action@v1.5.0
with:
token: ${{ inputs.token }}
conclusion: ${{ inputs.conclusion }}
check_id: ${{ inputs.check-id }}
64 changes: 64 additions & 0 deletions .github/actions/create-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This file is automatically added 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,
})
const job = jobs.find(j => j.name.endsWith(JOB_NAME))
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/checks-action@v1.5.0
id: check
with:
token: ${{ inputs.token }}
status: ${{ inputs.job-status }}
name: ${{ inputs.job-name }}
sha: ${{ inputs.sha }}
output: ${{ steps.workflow-job.outputs.result }}
20 changes: 20 additions & 0 deletions .github/actions/deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is automatically added 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
shell:
description: shell to run on
default: bash

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

name: Lint

inputs:
flags:
description: flags to pass to the commands
shell:
description: shell to run on
default: bash

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

name: Setup Repo
description: Setup a repo with standard tools

inputs:
node-version:
description: node version to use
default: 18.x
npm-version:
description: npm version to use
default: latest
cache:
description: whether to cache npm install or not
type: boolean
default: false
shell:
description: shell to run on
default: bash
deps:
description: whether to run the deps step
type: boolean
default: true
deps-command:
description: command to run for the dependencies step
default: install --ignore-scripts --no-audit --no-fund
deps-flags:
description: extra flags to pass to the dependencies step

runs:
using: composite
steps:
- name: Setup Git User
shell: ${{ inputs.shell }}
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: ${{ (inputs.cache && 'npm') || null }}

- name: Check Node Version
if: inputs.npm-version
id: node-version
shell: ${{ inputs.shell }}
run: |
NODE_VERSION=$(node --version)
echo $NODE_VERSION
if npx semver@7 -r "<=10" "$NODE_VERSION" --yes; then
echo "ten-or-lower=true" >> $GITHUB_OUTPUT
fi
if npx semver@7 -r "<=14" "$NODE_VERSION" --yes; then
echo "fourteen-or-lower=true" >> $GITHUB_OUTPUT
fi
- name: Update Windows npm
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: inputs.npm-version && runner.os == 'Windows' && steps.node-version.outputs.fourteen-or-lower
shell: ${{ inputs.shell }}
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install npm@7
if: inputs.npm-version && steps.node-version.outputs.ten-or-lower
shell: ${{ inputs.shell }}
run: npm i --prefer-online --no-fund --no-audit -g npm@7

- name: Install npm@${{ inputs.npm-version }}
if: inputs.npm-version && !steps.node-version.outputs.ten-or-lower
shell: ${{ inputs.shell }}
run: npm i --prefer-online --no-fund --no-audit -g npm@${{ inputs.npm-version }}

- name: npm Version
shell: ${{ inputs.shell }}
run: npm -v

- name: Setup Dependencies
if: inputs.deps
uses: ./.github/actions/deps
with:
command: ${{ inputs.deps-command }}
flags: ${{ inputs.deps-flags }}

- name: Add Problem Matcher
shell: ${{ inputs.shell }}
run: |
[[ -f ./.github/matchers/tap.json ]] && echo "::add-matcher::.github/matchers/tap.json"
17 changes: 17 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

name: Test

inputs:
flags:
description: flags to pass to the commands
shell:
description: shell to run on
default: bash

runs:
using: composite
steps:
- name: Test
shell: ${{ inputs.shell }}
run: npm test --ignore-scripts ${{ inputs.flags }}

0 comments on commit 76b3c6d

Please sign in to comment.