|
| 1 | +name: null-object package test with coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + # - never # Skip the workflow for debugging purposes; |
| 7 | + # - implement/package-ci # NB: For debugging only |
| 8 | + - develop |
| 9 | + - master |
| 10 | + paths: |
| 11 | + - ".github/workflows/null-object.yml" |
| 12 | + - "readme.md" |
| 13 | + - "package.json" |
| 14 | + - "src/**" |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: write-all |
| 20 | + env: |
| 21 | + GITHUB_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }} # NB: Cannot use 'GITHUB_' prefix |
| 22 | + |
| 23 | + name: Test, publish coverage |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up Node 20 |
| 29 | + uses: actions/setup-node@v3 |
| 30 | + with: |
| 31 | + node-version: 20 |
| 32 | + |
| 33 | + # Install dependencies and build the package to test in .usage folder |
| 34 | + - name: Install dependencies and build the package |
| 35 | + run: | |
| 36 | + npm install |
| 37 | + cd .usage && npm install |
| 38 | + cd ../ |
| 39 | + npm run package:build |
| 40 | +
|
| 41 | + - name: Testing the latest build at usage .usage subfolder |
| 42 | + working-directory: ./.usage |
| 43 | + run: | |
| 44 | + npm install |
| 45 | + npm run test:usage |
| 46 | +
|
| 47 | + - name: Run tests and collect coverage |
| 48 | + # NB: See https://app.codecov.io/gh/WhereJuly/60-1-oas-markdown-merger/tests/new |
| 49 | + # NB: See https://app.codecov.io/gh/WhereJuly/60-1-oas-markdown-merger/new |
| 50 | + run: npm run test:foundation -- --coverage |
| 51 | + |
| 52 | + # I need this step only run for the paths mentioned above AND for only `master` branch;` |
| 53 | + # create and push the `<package-name>@v<package-version>` tag to the monorepo |
| 54 | + # Take the package name and version from package.json |
| 55 | + - name: Create and push tag on master branch only |
| 56 | + # NB: For debugging |
| 57 | + # if: github.ref_name == 'implement/package-ci' |
| 58 | + if: github.ref_name == 'master' |
| 59 | + run: | |
| 60 | + # Extract package name and version from package.json |
| 61 | + PACKAGE_NAME=$(jq -r .name package.json) |
| 62 | + PACKAGE_VERSION=$(jq -r .version package.json) |
| 63 | +
|
| 64 | + # Create the tag |
| 65 | + # TAG="${PACKAGE_NAME}@${PACKAGE_VERSION}" # Only for monorepos |
| 66 | + TAG="${PACKAGE_VERSION}" |
| 67 | + git tag $TAG |
| 68 | +
|
| 69 | + # Push the tag to the repository |
| 70 | + git push origin $TAG |
| 71 | +
|
| 72 | + # - name: Push the package subtree to a dedicated repo |
| 73 | + # NB: See the code for this step in https://lean-web-enterprise.atlassian.net/browse/DCPLDOAS-68 |
| 74 | + |
| 75 | + - name: Upload coverage reports to Codecov |
| 76 | + # NB: For debugging |
| 77 | + # if: github.ref_name == 'implement/package-ci' |
| 78 | + if: github.ref_name == 'master' |
| 79 | + uses: codecov/codecov-action@v5 |
| 80 | + with: |
| 81 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 82 | + slug: WhereJuly/68-null-object |
0 commit comments