|
| 1 | +name: Lint, Test & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - 'dependabot/**' |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + commitlint: |
| 14 | + name: Lint commits |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v3 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + persist-credentials: false |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v3 |
| 24 | + with: |
| 25 | + node-version: 16.x |
| 26 | + cache: 'npm' |
| 27 | + - name: Install dependencies |
| 28 | + run: npm clean-install |
| 29 | + - name: Lint commit |
| 30 | + if: github.event_name == 'push' |
| 31 | + run: npx commitlint --from HEAD~1 --to HEAD --verbose |
| 32 | + - name: Lint commits |
| 33 | + if: github.event_name == 'pull_request' |
| 34 | + run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose |
| 35 | + codelint: |
| 36 | + name: Lint code |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Checkout code |
| 40 | + uses: actions/checkout@v3 |
| 41 | + with: |
| 42 | + persist-credentials: false |
| 43 | + - name: Setup Node.js |
| 44 | + uses: actions/setup-node@v3 |
| 45 | + with: |
| 46 | + node-version: 16.x |
| 47 | + cache: 'npm' |
| 48 | + - name: Install dependencies |
| 49 | + run: npm clean-install |
| 50 | + - name: Lint code |
| 51 | + run: npm run lint |
| 52 | + buildlint: |
| 53 | + name: Check built files |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Checkout code |
| 57 | + uses: actions/checkout@v3 |
| 58 | + with: |
| 59 | + persist-credentials: false |
| 60 | + - name: Setup Node.js |
| 61 | + uses: actions/setup-node@v3 |
| 62 | + with: |
| 63 | + node-version: 16.x |
| 64 | + cache: 'npm' |
| 65 | + - name: Install dependencies |
| 66 | + run: npm clean-install |
| 67 | + - name: Build files |
| 68 | + run: npm run build |
| 69 | + - name: Check built files |
| 70 | + run: git diff-files --quiet -w |
| 71 | + test: |
| 72 | + name: Run tests |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: |
| 75 | + - commitlint |
| 76 | + - codelint |
| 77 | + - buildlint |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v3 |
| 81 | + with: |
| 82 | + persist-credentials: false |
| 83 | + - name: Setup Node.js |
| 84 | + uses: actions/setup-node@v3 |
| 85 | + with: |
| 86 | + node-version: 16.x |
| 87 | + cache: 'npm' |
| 88 | + - name: Install dependencies |
| 89 | + run: npm clean-install |
| 90 | + - name: Run tests |
| 91 | + run: npm run test -- --forbid-only |
| 92 | + coverage: |
| 93 | + name: Test coverage |
| 94 | + runs-on: ubuntu-latest |
| 95 | + needs: |
| 96 | + - commitlint |
| 97 | + - codelint |
| 98 | + - buildlint |
| 99 | + permissions: |
| 100 | + contents: read |
| 101 | + pull-requests: write # to be able to comment on released pull requests |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v3 |
| 104 | + with: |
| 105 | + persist-credentials: false |
| 106 | + - name: Use Node.js |
| 107 | + uses: actions/setup-node@v3 |
| 108 | + with: |
| 109 | + node-version: 16.x |
| 110 | + cache: 'npm' |
| 111 | + - name: Install deps |
| 112 | + run: npm ci |
| 113 | + - name: Test code |
| 114 | + run: npm run test:coverage -- --forbid-only |
| 115 | + - name: Report coverage |
| 116 | + run: | |
| 117 | + echo "# Code coverage" >> $GITHUB_STEP_SUMMARY |
| 118 | + npx nyc report | sed --expression='1d;$d' >> $GITHUB_STEP_SUMMARY |
| 119 | + if: always() |
| 120 | +# release: |
| 121 | +# name: Release |
| 122 | +# concurrency: release |
| 123 | +# if: ${{ github.event_name == 'push' && github.actor != 'dependabot[bot]' }} |
| 124 | +# runs-on: ubuntu-latest |
| 125 | +# needs: |
| 126 | +# - commitlint |
| 127 | +# - codelint |
| 128 | +# - buildlint |
| 129 | +# - test |
| 130 | +# permissions: |
| 131 | +# contents: write # to be able to publish a GitHub release |
| 132 | +# issues: write # to be able to comment on released issues |
| 133 | +# pull-requests: write # to be able to comment on released pull requests |
| 134 | +# id-token: write # to enable use of OIDC for npm provenance |
| 135 | +# steps: |
| 136 | +# - name: Checkout |
| 137 | +# uses: actions/checkout@v3 |
| 138 | +# with: |
| 139 | +# fetch-depth: 0 |
| 140 | +# - name: Setup Node.js |
| 141 | +# uses: actions/setup-node@v3 |
| 142 | +# with: |
| 143 | +# node-version: "lts/*" |
| 144 | +# cache: 'npm' |
| 145 | +# - name: Install dependencies |
| 146 | +# run: npm clean-install |
| 147 | +# - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies |
| 148 | +# run: npm audit signatures |
| 149 | +# - name: Release |
| 150 | +# env: |
| 151 | +# NPM_CONFIG_PROVENANCE: true |
| 152 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 153 | +# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 154 | +# run: npx semantic-release |
0 commit comments