Skip to content

Commit

Permalink
test the package before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed May 5, 2024
1 parent dd251ad commit df1c734
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
name: Test npm package

on:
workflow_call:
inputs:
package:
type: string
default: everything-json@latest
description: package tarball or npm name to install
download:
type: boolean
default: false
description: whether the package artifact needs to be downloaded
workflow_dispatch:
inputs:
version:
description: "Package version to test"
required: true
package:
type: string
default: everything-json@latest
description: package tarball or npm name to install


jobs:
Expand Down Expand Up @@ -34,6 +45,11 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Download the package
uses: actions/download-artifact@v4
with:
name: ${{ inputs.package }}
if: inputs.download
- name: Create package.json
run: npm init --yes
- name: Set up the unit tests
Expand All @@ -45,7 +61,7 @@ jobs:
run: |
npm i chai@4.4.1 chai-spies chai-as-promised mocha typescript ts-node tsconfig-paths @types/chai@4.3.11 @types/chai-as-promised @types/mocha @types/node @types/geojson piscina
- name: Install everything-json from npm
run: npm install --force everything-json@${{ github.event.inputs.version }}
run: npm install ${{ inputs.package }}
shell: bash
- name: Run the unit tests
run: |
Expand Down Expand Up @@ -79,6 +95,11 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Download the package
uses: actions/download-artifact@v4
with:
name: ${{ inputs.package }}
if: inputs.download
- name: Create package.json
run: npm init --yes
- name: Set up the unit tests
Expand All @@ -92,7 +113,7 @@ jobs:
- name: Install everything-json from npm
run: |
[[ '${{ matrix.platform }}' =~ 'windows' ]] && subst M: `pwd` && cd M:/
npm install --force everything-json@${{ github.event.inputs.version }} --build-from-source
npm install ${{ inputs.package }} --build-from-source
shell: bash
- name: Run the unit tests
run: |
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,40 @@ jobs:
run: npx @mapbox/node-pre-gyp install
- name: Run unit tests
run: npm test


pack:
runs-on: ubuntu-latest
outputs:
package: ${{ steps.pack.outputs.package }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Pack
id: pack
run: |
npm pack
echo package=`echo everything-json-*.tgz` >> $GITHUB_OUTPUT
- name: Upload tarball
uses: actions/upload-artifact@v4
with:
name: ${{ steps.pack.outputs.package }}
path: ${{ steps.pack.outputs.package }}


test_package:
uses: mmomtchev/everything-json/.github/workflows/test-package.yml@main
needs: pack
with:
package: ${{ needs.pack.outputs.package }}
download: true

0 comments on commit df1c734

Please sign in to comment.