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

Add job to run tests on push #22

Merged
merged 3 commits into from
Jul 21, 2022
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
62 changes: 62 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: test-and-publish
on: push

jobs:
test:
runs-on: ubuntu-latest
name: Run unit tests
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Install dependencies
run: yarn
- name: Check types
run: yarn typecheck
- name: Lint
run: yarn lint
- name: Unit tests
run: yarn jest
publish:
name: Publish to NPM Package Registry
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main
# limit releases to version changes - https://github.com/EndBug/version-check
- name: Check version changes
uses: EndBug/version-check@v1
id: version_check
with:
# diff the commits rather than commit message for version changes
diff-search: true

- name: Version update detected
if: steps.version_check.outputs.changed == 'true'
run: 'echo "Version change found! New version: ${{ steps.version_check.outputs.version }} (${{ steps.version_check.outputs.type }})"'

- name: Setup .npmrc file for NPM registry
if: steps.version_check.outputs.changed == 'true'
uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
if: steps.version_check.outputs.changed == 'true'
run: yarn

- name: Build library
if: steps.version_check.outputs.changed == 'true'
run: yarn build

- name: Publish package to NPM
if: steps.version_check.outputs.changed == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to add this secret before we can actually release the package! 🚀

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"generate-app": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js -- create-plugin 'Sample app' 'sample-org' 'This is a sample app.' 'app' 't' 't'",
"generate-panel": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js -- create-plugin 'Sample panel' 'sample-org' 'This is a sample panel.' 'panel' 't' 't'",
"generate-datasource": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js -- create-plugin 'Sample datasource' 'sample-org' 'This is a sample datasource.' 'datasource' 't' 't'",
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx ./src",
"lint:fix": "yarn lint --fix",
"test": "jest --watch",
"typecheck": "tsc --noEmit"
Expand Down Expand Up @@ -62,5 +62,8 @@
"events": {
"start": "cls || clear"
}
},
"engines": {
"node": ">=16"
}
}