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

Workflows #41

Open
wants to merge 31 commits into
base: new-ci-cd
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0644974
Add dependabot file
Skenvy Apr 20, 2023
85706b8
Extensive gitignore
Skenvy Apr 20, 2023
dc82003
Into the wild blue yonder
Apr 20, 2023
9ab5d01
Add the missing runs-on in cql
Apr 20, 2023
bf7add4
Update the nodev from a lockv 1 to a lockv 2 version
Apr 20, 2023
b872431
Run tests in xvfb
Apr 21, 2023
4afecea
sudo apt
Apr 21, 2023
774ea6a
use the recommeneded "xvfb-maybe"
Apr 21, 2023
efc44c3
Clean make
Apr 21, 2023
0a3a5d5
Workflows pr scoped test (#2)
Skenvy Apr 21, 2023
1789933
Update lock
Apr 21, 2023
c77c1ac
Add legacy peer deps to make setup
Apr 21, 2023
e24c3c8
Add the smaller testing scope to test
Apr 21, 2023
1255980
Merge branch 'main' into workflows
Apr 21, 2023
1e99219
Merge branch 'yoavbls:main' into workflows
Skenvy Apr 22, 2023
215c516
Merge branch 'workflows' of github.com:Skenvy/pretty-ts-errors into w…
Skenvy Apr 22, 2023
a0b9de5
Merge branch 'main' into workflows
Skenvy Apr 22, 2023
754e708
Roll make recipes into either themselves or package json scripts
Apr 22, 2023
0d1bfdd
Move the mac and win runners to a comment
Skenvy Apr 22, 2023
2be4db5
Merge branch 'main' into workflows
Skenvy Apr 23, 2023
be064d1
Merge branch 'main' into workflows
Apr 25, 2023
6bf696d
Remove action sha pins
Apr 25, 2023
792af8b
Swap to major only versions
Apr 25, 2023
c245495
Emoji diff and lint in its own job
Apr 25, 2023
721b96c
Fix spelling
Apr 25, 2023
de8ae6e
format test wf
Apr 25, 2023
834f79a
minify ignore, add prepack
Apr 25, 2023
d18a17f
Include vsce test in test and add in a draft release
Apr 25, 2023
c4bc1d4
specify out as the file glob in package and rename *-tests in scripts
Apr 25, 2023
0f3d91c
Remove ts-loader
Apr 25, 2023
2b8ce82
Fix multi-artifact download paths in release find files
Apr 25, 2023
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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
172 changes: 172 additions & 0 deletions .github/workflows/release.yml
Skenvy marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,172 @@
name: Build Release Publish
on:
push:
branches:
- 'main'
workflow_dispatch:

permissions: {}

defaults:
run:
shell: bash

env:
development_node_version: 18.12.1

jobs:
# Gate the build -> release -> publish jobs with the test workflow.
test:
name: 🧪 CI
permissions:
actions: read
contents: read
security-events: write
uses: ./.github/workflows/test.yml

# 🛑 Check both whether the package's version field has changed, and if that
# version's value already exists in a known release, to determine if we should
# proceed with building and releasing.
workflow-conditions:
name: 🛑 Stop release collisions
runs-on: ubuntu-latest
outputs:
version-file-changed: ${{ steps.version-file-check.outputs.version-file-changed }}
version-tag-exists: ${{ steps.version-tag-exists.outputs.version-tag-exists }}
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Check if version files changed
id: version-file-check
run: |
export VERSION_FILE="package.json"
[ "$(git diff HEAD^1.. --name-only | grep -e "^$VERSION_FILE$")" == "$VERSION_FILE" ] && echo "version-file-changed=${{toJSON(true)}}" >> $GITHUB_OUTPUT || echo "version-file-changed=${{toJSON(false)}}" >> $GITHUB_OUTPUT
- name: Notify on version-file-check
run: echo "::Notice::version-file-changed is ${{ fromJSON(steps.version-file-check.outputs.version-file-changed) }}"
- name: Check if version specified in version file has not released.
id: version-tag-exists
run: |
git fetch --tags
export VER=$(grep package.json -e "\"version\":" | cut -d \" -f 4)
[ -z "$(git tag -l "v$VER")" ] && echo "version-tag-exists=${{toJSON(false)}}" >> $GITHUB_OUTPUT || echo "version-tag-exists=${{toJSON(true)}}" >> $GITHUB_OUTPUT
- name: Notify on version-tag-exists
run: echo "::Notice::version-tag-exists is ${{ fromJSON(steps.version-tag-exists.outputs.version-tag-exists) }}"

# We want to build release and publish automatically if "version-file-changed"
# is true on push. Or manually if workflow_dispatch.
# Both triggers need "version-tag-exists" is false.
build-npm:
name: Build NPM 🧱
needs: [test, workflow-conditions]
if: >-
${{ ((fromJSON(needs.workflow-conditions.outputs.version-file-changed) == true && github.event_name == 'push') ||
github.event_name == 'workflow_dispatch') && fromJSON(needs.workflow-conditions.outputs.version-tag-exists) == false }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
- name: 🧱 Install build dependencies
run: npm run setup
- name: 🧱 Build
run: npm pack
- name: 🆙 Upload dists
uses: actions/upload-artifact@v3
with:
name: npm-package
path: pretty-ts-errors-*.tgz
if-no-files-found: error

build-vsce:
name: Build VSCE 🧱
needs: [test, workflow-conditions]
if: >-
${{ ((fromJSON(needs.workflow-conditions.outputs.version-file-changed) == true && github.event_name == 'push') ||
github.event_name == 'workflow_dispatch') && fromJSON(needs.workflow-conditions.outputs.version-tag-exists) == false }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
- name: 🧱 Install build dependencies
run: npm run setup
- name: 🧱 Build
run: npm run build
- name: 🆙 Upload dists
uses: actions/upload-artifact@v3
with:
name: vsce-package
path: pretty-ts-errors-*.vsix
if-no-files-found: error

release:
name: Release 🚰
needs: [build-npm, build-vsce]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🆒 Download dists
uses: actions/download-artifact@v3
- name: 🚰 Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
export VER=$(grep package.json -e "\"version\":" | cut -d \" -f 4) &&
gh release create v$VER --generate-notes -t "v$VER" --draft
"$(find . | grep -e npm-package/pretty-ts-errors-*\.tgz)#npm package"
"$(find . | grep -e vsce-package/pretty-ts-errors-*\.vsix)#vsce package"

publish-github:
name: Publish GitHub 🐱‍👤
needs: [release]
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🆒 Download dists
uses: actions/download-artifact@v3
with:
name: npm-package
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
registry-url: 'https://npm.pkg.github.com'
- name: 📦 Publish
run: npm run workflow_publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
name: Publish NPM 🟥
needs: [release]
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🆒 Download dists
uses: actions/download-artifact@v3
with:
name: npm-package
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
registry-url: 'https://registry.npmjs.org'
- name: 📦 Publish
run: npm run workflow_publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
124 changes: 124 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,124 @@
name: CI
on:
push:
branches-ignore:
- 'main'
pull_request:
branches:
- 'main'
workflow_call:

permissions: {}

defaults:
run:
shell: bash

env:
development_node_version: 18.12.1

jobs:
# On every push to every branch, lint.
lint:
name: 🔬 Lint
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
- name: 🧱 Install build dependencies
run: npm run setup
- name: 🔬 Lint
run: npm run lint

# On a push to a non-trunk branch, do a "quick" test of the package.
quick-test:
name: 🧪 Quick Test
if: ${{ github.event_name == 'push' && !(github.event.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
- name: 🧱 Install build dependencies
run: npm run setup
- name: 🧪 Test
run: npm run workflow_test

# On a push to the trunk branch, or a PR (or manual dispatch), run the full
# set of tests against the targeted supported major versions.
full-test:
name: 🧪 Full Test
if: >-
${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.event.ref == 'refs/heads/main') }}
runs-on: '${{ matrix.os }}'
strategy:
fail-fast: false
matrix:
version: ['16', '18', '20']
os: [ubuntu-latest] # TODO: stabilise macOS-latest, windows-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🟩 Set up Node ${{ matrix.version }}
uses: actions/setup-node@v3
with:
node-version: '${{ matrix.version }}'
- name: 🧱 Install build dependencies
run: npm run setup
- name: 🧪 Test
run: npm run workflow_test

# On a push to the trunk branch, or a PR (or manual dispatch), run the build
# to confirm that the vsce build is happy.
is-vsce-happy:
name: 🧪 VSCE Test
if: >-
${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.event.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 🟩 Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.development_node_version }}
- name: 🧱 Install build dependencies
run: npm run setup
- name: 🧪 Test
run: npm run build

# On a push to the trunk branch, or a PR (or manual dispatch), do a CodeQL analysis.
codeql:
name: 👨‍💻 CodeQL
if: >-
${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && github.event.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
- name: 👨‍💻 Init CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript
queries: +security-extended,security-and-quality
- name: 🧱 Autobuild
uses: github/codeql-action/autobuild@v2
- name: 👨‍💻 Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:javascript"
10 changes: 10 additions & 0 deletions .gitignore
@@ -1,5 +1,15 @@
# build / generate output
out
dist

# Dependency directories
node_modules

# Stores VSCode versions used for testing VSCode extensions
.vscode-test/

# Output of 'npm pack'
*.tgz

# Output of 'vsce package'
*.vsix
2 changes: 1 addition & 1 deletion .vscode/launch.json
Expand Up @@ -28,7 +28,7 @@
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
"preLaunchTask": "tasks: watch-src"
}
]
}
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Expand Up @@ -19,7 +19,7 @@
},
{
"type": "npm",
"script": "watch-tests",
"script": "watch-src",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
Expand All @@ -29,10 +29,10 @@
"group": "build"
},
{
"label": "tasks: watch-tests",
"label": "tasks: watch-src",
"dependsOn": [
"npm: watch",
"npm: watch-tests"
"npm: watch-src"
],
"problemMatcher": []
}
Expand Down