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 #7

Merged
merged 32 commits into from
Oct 21, 2024
Merged

CI #7

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ec985c8
ci: consolidate and refactor workflow
seansica Oct 18, 2024
3741f0a
ci: consolidate and refactor workflow
seansica Oct 18, 2024
c58afbd
ci: upgrade semantic-release-action plugin to v4
seansica Oct 18, 2024
72fbc70
ci: change semantic-release plugins
seansica Oct 18, 2024
73663d3
test(ci): identifying reason for no files found in .test-logs/
seansica Oct 18, 2024
6645e65
fix(ci): add include-hidden-files option to "Upload test logs" step
seansica Oct 18, 2024
2687c24
fix(ci): replace cycjimmy/semantic-release-action@v4 plugin with manu…
seansica Oct 18, 2024
de4abf0
fix(ci): add missing steps to publish job
seansica Oct 18, 2024
15304fc
style(ci): format ci.yml workflow file
seansica Oct 21, 2024
a9d1401
fix(ci): remove redundant build step
seansica Oct 21, 2024
ba03454
fix(ci): allow semantic-release to skip husky git hooks
seansica Oct 21, 2024
15f992c
fix(ci): add packages:write scope to ci workflow
seansica Oct 21, 2024
ea64949
fix(package.json): correct formatting of repository.url
seansica Oct 21, 2024
7c4323b
fix(ci): add NPM_TOKEN to semantic-release
seansica Oct 21, 2024
fbc6e96
fix(ci): rename build job to test
seansica Oct 21, 2024
0d359c8
feat(ci): trigger build
seansica Oct 21, 2024
8cc2802
fix(ci): install only prod deps during publish job to stop Husky x se…
seansica Oct 21, 2024
e1f83bf
fix(ci): add HUSKY=0 in publish job to disable husky
seansica Oct 21, 2024
026e247
fix(ci): change flag that handles omitting dev dependencies from the …
seansica Oct 21, 2024
669a732
fix(husky): use script-based workflow for installing husky to support…
seansica Oct 21, 2024
cb6a9a7
fix(ci): remove NPM_TOKEN from publish job
seansica Oct 21, 2024
fdfabd1
fix(package-lock): synchronize version property
seansica Oct 21, 2024
e765a7c
fix(husky): try simplifying npm prepare script
seansica Oct 21, 2024
b760ba5
build: add .npmrc config
seansica Oct 21, 2024
e72f620
fix(husky): remove install script
seansica Oct 21, 2024
d524620
fix(semantic-release): test removing semantic-release/npm plugin
seansica Oct 21, 2024
64e8384
Merge remote-tracking branch 'origin/main' into beta
seansica Oct 21, 2024
ed921b8
fix(semantic-release): test restoring semantic-release/npm plugin
seansica Oct 21, 2024
ffe4c60
fix(ci): try using GH_TOKEN instead of GITHUB_TOKEN
seansica Oct 21, 2024
e53c7bf
fix(package.json): update repository proeprty
seansica Oct 21, 2024
f7dfc8c
fix(ci): add NODE_AUTH_TOKEN to publish job
seansica Oct 21, 2024
f8144a1
fix(ci): restore GITHUB_TOKEN on release step
seansica Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 102 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,120 @@
name: CI
name: CI and Release

on:
push:
branches:
- main
- next
- beta
- alpha
- '*.*.x' # Matches branches like '1.2.x', '2.3.x'
- '*.x' # Matches branches like '1.x', '2.x'
pull_request:
branches:
- main
- next
- beta
- alpha
- '*.*.x' # Matches PRs targeting '1.2.x', '2.3.x'
- '*.x' # Matches PRs targeting '1.x', '2.x'

permissions:
contents: read # for checkout
contents: read

jobs:
# Job 1: Commit Linting
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to check commit differences
fetch-depth: 0 # Fetch full history to check commit differences

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Install dependencies
run: npm ci
- name: Validate all commits from push
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Validate all commits
run: npx commitlint --from ${{ github.event.pull_request.base.sha || github.event.before }} --to ${{ github.event.pull_request.head.sha || github.sha }} --verbose

# Job 2: Build and Test
test:
runs-on: ubuntu-latest
needs: [commitlint]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm run test

- name: List test logs
run: ls -la .test-logs/

- name: Upload test logs
uses: actions/upload-artifact@v4
if: always()
with:
name: test-logs
path: .test-logs/**
include-hidden-files: true

- name: Verify integrity of dependencies
run: npm audit signatures

# Job 3: Publish
publish:
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: write # To publish a GitHub release
packages: write # To publish to GitHub Package registry
issues: write # To comment on released issues
pull-requests: write # To comment on released pull requests
id-token: write # To enable OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@mitre-attack'

- name: Install dependencies
run: npm clean-install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} DO NOT USE
HUSKY: 0 # Temporarily disables all Git hooks
run: npx semantic-release
67 changes: 0 additions & 67 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@mitre-attack:registry=https://npm.pkg.github.com
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"test:interactive": "vitest",
"export": "npm pack",
"clean": "rm -rf test/**/*.js test/**/*.js.map test/**/*.d.ts test/**/*.ts.map src/**/*.js src/**/*.js.map src/**/*.d.ts",
"prepare": "husky",
"prepare": "husky || true",
"lint": "npx eslint src",
"lint:fix": "npm run lint -- --fix",
"prettier": "npx prettier src --check",
Expand Down