|
| 1 | +name: Test |
| 2 | + |
| 3 | +# This workflow will lint and test a plugin whenever it or CI changes. |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +# Cancel in-progress runs for pull requests when developers push changes. |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 17 | + |
| 18 | +jobs: |
| 19 | + changes: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + plugins: ${{ steps.filter.outputs.changes }} |
| 23 | + steps: |
| 24 | + # Pull requests do not need to check out the code to detect changes |
| 25 | + # because the action fetches changed files through the API. |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + if: github.event_name != 'pull_request' |
| 28 | + - uses: dorny/paths-filter@v3 |
| 29 | + id: filter |
| 30 | + with: |
| 31 | + filters: | |
| 32 | + coder: |
| 33 | + - ".github/workflows/build.yaml" |
| 34 | + - "plugins/backstage-plugin-coder/**" |
| 35 | + plugin: |
| 36 | + needs: changes |
| 37 | + runs-on: ubuntu-latest |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + plugin: ${{ fromJSON(needs.changes.outputs.plugins) }} |
| 41 | + name: ${{ matrix.plugin }} |
| 42 | + defaults: |
| 43 | + run: |
| 44 | + working-directory: plugins/backstage-plugin-${{ matrix.plugin }} |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - uses: actions/setup-node@v4 |
| 48 | + with: |
| 49 | + node-version-file: .node-version |
| 50 | + cache: yarn |
| 51 | + - run: yarn install --frozen-lockfile |
| 52 | + - run: yarn lint |
| 53 | + - run: yarn tsc |
| 54 | + - run: yarn test |
| 55 | + - run: yarn build |
| 56 | + # Version it with the SHA and upload to the run as an artifact in case |
| 57 | + # someone needs to download it for testing. |
| 58 | + - run: yarn version --new-version "0.0.0-devel+$GITHUB_SHA" |
| 59 | + - run: yarn pack |
| 60 | + - uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: ${{ matrix.plugin }} |
| 63 | + path: plugins/backstage-plugin-${{ matrix.plugin }}/*.tgz |
0 commit comments