Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 48 additions & 24 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,64 @@
# This workflow will run tests using node and then publish a package to NPM when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package
name: Publish Package

on:
release:
types: [created]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn test

publish-npm:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lockfile
- run: yarn build
- run: npm publish --provenance --access public

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Extract version from tag
id: get_version
run: |
# Use the tag name directly and strip an optional leading 'v'
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"

# Basic validation: ensure VERSION looks like a SemVer (e.g. 1.2.3, 1.2.3-beta.1)
if ! echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){2}(-[0-9A-Za-z.-]+)?$'; then
echo "Error: Tag '${{ github.ref_name }}' does not contain a valid semver version (got '$VERSION')." >&2
exit 1
fi

echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing version: $VERSION"

- name: Update package.json version
run: |
VERSION="${{ steps.get_version.outputs.version }}"

# Guard against empty or invalid version
if [ -z "$VERSION" ]; then
echo "Error: Version output is empty" >&2
exit 1
fi

# Use yarn version to keep yarn.lock in sync
yarn version --new-version "$VERSION" --no-git-tag-version

- name: Run tests
run: yarn test

- name: Build
run: yarn build

- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
138 changes: 134 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,141 @@ module.exports = {
'!src/**/*.spec.ts',
],
coverageThreshold: {
// Note: Global thresholds are intentionally lower because they include
// modules without tests. Specific per-file thresholds ensure 90%+ coverage
// for all modules that have test coverage.
global: {
branches: 15,
functions: 15,
lines: 25,
statements: 25,
branches: 13,
functions: 23,
lines: 27,
statements: 27,
},
// Specific thresholds for modules with tests
'src/apis/ArtifactApi.ts': {
branches: 85,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/DashboardApi.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/GroupApi.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/HealthApi.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/LoginApi.ts': {
branches: 60,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/ProjectApi.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/ResultApi.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/apis/RunApi.ts': {
branches: 75,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Artifact.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/ArtifactList.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Dashboard.ts': {
branches: 80,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/DashboardList.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Group.ts': {
branches: 75,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/GroupList.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Pagination.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Project.ts': {
branches: 85,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/ProjectList.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Result.ts': {
branches: 95,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/ResultList.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/Run.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
'src/models/RunList.ts': {
branches: 90,
functions: 100,
lines: 90,
statements: 90,
},
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ibutsu-client-ts",
"version": "2.0.1",
"version": "0.0.0-development",
"description": "A TypeScript client for the Ibutsu API",
"license": "MIT",
"main": "dist/cjs/index.js",
Expand Down
Loading