|
| 1 | +name: Usage Metrics Dashboard |
| 2 | + |
| 3 | +# Re-usable workflows use the `workflow_call` trigger |
| 4 | +# https://docs.github.com/en/actions/sharing-automations/reusing-workflows#creating-a-reusable-workflow |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + |
| 8 | +# Setup the environment with the extension name for easy re-use |
| 9 | +# Also set the GH_TOKEN for the release-extension action to be able to use gh |
| 10 | +env: |
| 11 | + EXTENSION_NAME: usage-metrics-dashboard |
| 12 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 13 | + |
| 14 | +jobs: |
| 15 | + extension: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + defaults: |
| 18 | + run: |
| 19 | + working-directory: ./extensions/${{ env.EXTENSION_NAME }} |
| 20 | + |
| 21 | + steps: |
| 22 | + # Checkout the repository so the rest of the actions can run with no issue |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + # We want to fail quickly if the linting fails, do that first |
| 26 | + - uses: ./.github/actions/lint-extension |
| 27 | + with: |
| 28 | + extension-name: ${{ env.EXTENSION_NAME }} |
| 29 | + |
| 30 | + # --- |
| 31 | + # Run R tests |
| 32 | + # --- |
| 33 | + |
| 34 | + - uses: r-lib/actions/setup-r@v2 |
| 35 | + with: |
| 36 | + r-version: '4.3.3' |
| 37 | + |
| 38 | + - uses: r-lib/actions/setup-renv@v2 |
| 39 | + with: |
| 40 | + working-directory: extensions/${{ env.EXTENSION_NAME }} |
| 41 | + |
| 42 | + - run: Rscript -e 'install.packages(c("testthat"))' |
| 43 | + working-directory: extensions/${{ env.EXTENSION_NAME }} |
| 44 | + |
| 45 | + - run: Rscript -e 'testthat::test_local()' |
| 46 | + working-directory: extensions/${{ env.EXTENSION_NAME }} |
| 47 | + |
| 48 | + # Now that the extension is built we need to upload an artifact to pass |
| 49 | + # to the package-extension action that contains the files we want to be |
| 50 | + # included in the extension |
| 51 | + # This only includes necessary files for the extension to run leaving out |
| 52 | + # the files that were used to build the /dist/ directory |
| 53 | + - name: Upload built extension |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: ${{ env.EXTENSION_NAME }} |
| 57 | + # Replace the below with the files your content needs |
| 58 | + path: | |
| 59 | + extensions/${{ env.EXTENSION_NAME }}/app.R |
| 60 | + extensions/${{ env.EXTENSION_NAME }}/R/ |
| 61 | + extensions/${{ env.EXTENSION_NAME }}/renv.lock |
| 62 | + extensions/${{ env.EXTENSION_NAME }}/www/styles.css |
| 63 | + extensions/${{ env.EXTENSION_NAME }}/manifest.json |
| 64 | +
|
| 65 | + # Package up the extension into a TAR using the package-extension action |
| 66 | + - uses: ./.github/actions/package-extension |
| 67 | + with: |
| 68 | + extension-name: ${{ env.EXTENSION_NAME }} |
| 69 | + artifact-name: ${{ env.EXTENSION_NAME }} |
| 70 | + |
| 71 | + connect-integration-tests: |
| 72 | + needs: extension |
| 73 | + uses: ./.github/workflows/connect-integration-tests.yml |
| 74 | + secrets: inherit |
| 75 | + with: |
| 76 | + extensions: '["usage-metrics-dashboard"]' # JSON array format to match the workflow input schema |
| 77 | + |
| 78 | + release: |
| 79 | + runs-on: ubuntu-latest |
| 80 | + needs: [extension, connect-integration-tests] |
| 81 | + # Release the extension using the release-extension action |
| 82 | + # Will only create a GitHub release if merged to `main` and the semver |
| 83 | + # version has been updated |
| 84 | + steps: |
| 85 | + # Checkout the repository so the rest of the actions can run with no issue |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - uses: ./.github/actions/release-extension |
| 89 | + with: |
| 90 | + extension-name: ${{ env.EXTENSION_NAME }} |
0 commit comments