ci(project): gh action test workflow #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Redac CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
list-packages: | |
name: List Packages | |
runs-on: ubuntu-latest | |
outputs: | |
packages: ${{ steps.get-folders.outputs.packages }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: get-folders | |
working-directory: packages | |
shell: bash | |
run: | | |
packages=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name)') | |
echo "packages=$packages" >> $GITHUB_OUTPUT | |
test: | |
name: Package Test | |
needs: [list-packages] | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false # avoid cancel all in-progress jobs if any fails | |
matrix: | |
node-version: [18.x] | |
package: ${{ fromJson(needs.list-packages.outputs.packages)}} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install package dependencies | |
run: yarn --frozen-lockfile | |
- name: Test | |
shell: bash | |
run: | | |
if [ ${{ matrix.package }} != redac ]; then | |
npx lerna run test --scope=@redac/${{ matrix.package }} | |
else | |
npx lerna run test --scope=${{ matrix.package }} | |
fi |