|
| 1 | +name: "Test" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - "**.md" |
| 7 | + pull_request: |
| 8 | + paths-ignore: |
| 9 | + - "**.md" |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + name: Test |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + runs-on: [ubuntu-latest, macos-latest, windows-latest] |
| 21 | + fail-fast: false |
| 22 | + runs-on: ${{ matrix.runs-on }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + name: Checkout [Pull Request] |
| 26 | + if: ${{ github.event_name == 'pull_request' }} |
| 27 | + with: |
| 28 | + ref: ${{ github.event.pull_request.head.sha }} |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - uses: actions/checkout@v2 |
| 32 | + name: Checkout [Push] |
| 33 | + if: ${{ github.event_name != 'pull_request' }} |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Set Node.js 16.x |
| 38 | + uses: actions/setup-node@v3 |
| 39 | + with: |
| 40 | + node-version: 16 |
| 41 | + |
| 42 | + - name: Install |
| 43 | + run: npm ci |
| 44 | + |
| 45 | + - name: Compile |
| 46 | + run: npm run build |
| 47 | + |
| 48 | + - name: Test default PR Workflow |
| 49 | + if: github.event_name == 'pull_request' |
| 50 | + uses: ./ |
| 51 | + with: |
| 52 | + main-branch-name: ${{ github.base_ref }} |
| 53 | + - name: Verify default PR Workflow |
| 54 | + if: github.event_name == 'pull_request' |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + BASE_SHA=$(echo $(git merge-base origin/${{github.base_ref}} HEAD)) |
| 58 | + HEAD_SHA=$(git rev-parse HEAD) |
| 59 | + node -e "if(process.env.NX_BASE == '${BASE_SHA}') console.log('Base set correctly'); else { throw new Error('Base not set correctly!');}" |
| 60 | + node -e "if(process.env.NX_HEAD == '${HEAD_SHA}') console.log('Head set correctly'); else { throw new Error('Head not set correctly!');}" |
| 61 | +
|
| 62 | + - name: Test default Push Workflow |
| 63 | + if: github.event_name != 'pull_request' |
| 64 | + uses: ./ |
| 65 | + with: |
| 66 | + main-branch-name: ${{ github.ref_name }} |
| 67 | + - name: Verify default Push Workflow |
| 68 | + if: github.event_name != 'pull_request' |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + BASE_SHA=$(echo $(git rev-parse HEAD~1)) |
| 72 | + HEAD_SHA=$(echo $(git rev-parse HEAD)) |
| 73 | + node -e "if(process.env.NX_BASE == '${BASE_SHA}') console.log('Base set correctly'); else { throw new Error('Base not set correctly!');}" |
| 74 | + node -e "if(process.env.NX_HEAD == '${HEAD_SHA}') console.log('Head set correctly'); else { throw new Error('Head not set correctly!');}" |
0 commit comments