|
| 1 | +name: Build |
| 2 | +# |
| 3 | +# This workflow validates that the commit in question can be built successfully |
| 4 | +# in several environments: |
| 5 | +# |
| 6 | +# Systems: Ubuntu, MacOS, Windows |
| 7 | +# Node: 20 |
| 8 | +# |
| 9 | +# After the build is successful, the compiled assets are uploaded as an artifact |
| 10 | +# to the workflow run. This allows us to download the compiled assets and use |
| 11 | +# them in other workflows. |
| 12 | +# |
| 13 | +# Note: we need to skip the nx cache b/c it does not contain the compiled assets |
| 14 | +# |
| 15 | + |
| 16 | +on: |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + system: |
| 20 | + required: false |
| 21 | + default: 'macos-latest' |
| 22 | + node-version: |
| 23 | + required: false |
| 24 | + default: '20' |
| 25 | + experimental: |
| 26 | + required: false |
| 27 | + default: 'false' |
| 28 | + ref: |
| 29 | + description: 'The branch or tag to checkout' |
| 30 | + required: false |
| 31 | + workflow_call: |
| 32 | + inputs: |
| 33 | + system: |
| 34 | + required: false |
| 35 | + type: string |
| 36 | + default: 'macos-latest' |
| 37 | + node-version: |
| 38 | + required: false |
| 39 | + type: string |
| 40 | + default: '20' |
| 41 | + experimental: |
| 42 | + required: false |
| 43 | + type: boolean |
| 44 | + default: false |
| 45 | + ref: |
| 46 | + description: 'The branch or tag to checkout' |
| 47 | + required: false |
| 48 | + type: string |
| 49 | + default: ${{ github.head_ref }} |
| 50 | + |
| 51 | +permissions: |
| 52 | + contents: read |
| 53 | + pull-requests: write |
| 54 | + |
| 55 | +defaults: |
| 56 | + run: |
| 57 | + shell: bash |
| 58 | + |
| 59 | +jobs: |
| 60 | + # ---------- Validate build for various environments ---------- # |
| 61 | + build: |
| 62 | + strategy: |
| 63 | + fail-fast: false |
| 64 | + matrix: |
| 65 | + system: |
| 66 | + - ${{ inputs.system }} |
| 67 | + node-version: |
| 68 | + - ${{ inputs.node-version }} |
| 69 | + experimental: |
| 70 | + - ${{ inputs.experimental }} |
| 71 | + runs-on: ${{ matrix.system }} |
| 72 | + continue-on-error: ${{ matrix.experimental }} |
| 73 | + timeout-minutes: 10 |
| 74 | + name: Build ${{ matrix.system }}, node v${{ matrix.node-version }} |
| 75 | + steps: |
| 76 | + - name: Checkout PR branch |
| 77 | + uses: actions/checkout@v4 |
| 78 | + with: |
| 79 | + ref: ${{ inputs.ref || github.head_ref }} |
| 80 | + fetch-depth: 0 |
| 81 | + |
| 82 | + - name: Setup Job and Install Dependencies |
| 83 | + uses: ./.github/actions/setup-job |
| 84 | + with: |
| 85 | + node-version: ${{ matrix.node-version }} |
| 86 | + |
| 87 | + - name: Build the project |
| 88 | + if: always() |
| 89 | + run: yarn build |
| 90 | + |
| 91 | + # This step will evaluate the repo status and report the change |
| 92 | + # If there are changes, capture the changes and upload them as an artifact |
| 93 | + - name: Check if there are changes |
| 94 | + if: always() |
| 95 | + run: | |
| 96 | + if [[ -z $(git status --porcelain) ]]; then |
| 97 | + echo "No changes detected" |
| 98 | + exit 0 |
| 99 | + else |
| 100 | + echo "Changes detected" |
| 101 | + git status |
| 102 | + exit 1 |
| 103 | + fi |
0 commit comments