|
1 |
| -on: workflow_dispatch |
| 1 | +on: |
| 2 | + workflow_dispatch: |
| 3 | + pull_request: |
| 4 | + types: [opened, synchronize] |
| 5 | + paths: |
| 6 | + - 'packages/next/build/swc/**' |
2 | 7 |
|
3 | 8 | name: Build next-swc native binaries
|
4 | 9 |
|
5 | 10 | jobs:
|
6 |
| - build-native: |
| 11 | + build: |
7 | 12 | strategy:
|
8 | 13 | matrix:
|
9 | 14 | os: [ubuntu-18.04, macos-latest, windows-latest]
|
10 |
| - description: [default] |
11 |
| - include: |
12 |
| - - os: ubuntu-18.04 |
13 |
| - target: x86_64-unknown-linux-gnu |
14 |
| - - os: windows-latest |
15 |
| - target: x86_64-pc-windows-msvc |
16 |
| - - os: macos-latest |
17 |
| - target: x86_64-apple-darwin |
18 |
| - - os: macos-latest |
19 |
| - target: aarch64-apple-darwin |
20 |
| - description: m1 |
21 |
| - |
22 |
| - name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14 |
| 15 | + |
| 16 | + name: stable - ${{ matrix.os }} - node@14 |
23 | 17 | runs-on: ${{ matrix.os }}
|
24 | 18 |
|
25 | 19 | steps:
|
26 | 20 | - uses: actions/checkout@v2
|
| 21 | + |
27 | 22 | - name: Setup node
|
28 | 23 | uses: actions/setup-node@v2
|
29 | 24 | with:
|
30 | 25 | node-version: 14
|
31 | 26 | check-latest: true
|
| 27 | + |
32 | 28 | - name: Install
|
33 | 29 | uses: actions-rs/toolchain@v1
|
34 | 30 | with:
|
| 31 | + toolchain: stable |
35 | 32 | profile: minimal
|
36 |
| - toolchain: nightly-2021-03-25 |
37 |
| - target: ${{ matrix.target }} |
| 33 | + |
38 | 34 | - name: Cache cargo registry
|
39 | 35 | uses: actions/cache@v1
|
40 | 36 | with:
|
41 | 37 | path: ~/.cargo/registry
|
42 | 38 | key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
| 39 | + |
43 | 40 | - name: Cache cargo index
|
44 | 41 | uses: actions/cache@v1
|
45 | 42 | with:
|
46 | 43 | path: ~/.cargo/git
|
47 | 44 | key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
48 |
| - - name: Cache native binary |
49 |
| - id: binary-cache |
50 |
| - uses: actions/cache@v2 |
| 45 | + |
| 46 | + - name: Cache NPM dependencies |
| 47 | + uses: actions/cache@v1 |
51 | 48 | with:
|
52 |
| - path: packages/next/native/** |
53 |
| - key: next-swc-nightly-2021-03-25-${{ matrix.target }}-${{ hashFiles('packages/next/build/swc/**') }} |
| 49 | + path: node_modules |
| 50 | + key: npm-cache-${{ matrix.os }}-node@14-${{ hashFiles('yarn.lock') }} |
| 51 | + |
| 52 | + - name: 'Install dependencies' |
| 53 | + run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000 |
| 54 | + |
54 | 55 | - name: 'Build'
|
55 |
| - if: steps.binary-cache.outputs.cache-hit != true |
56 |
| - run: yarn build-native --target ${{ matrix.target }} |
| 56 | + run: yarn --cwd packages/next build-native |
57 | 57 | env:
|
58 | 58 | MACOSX_DEPLOYMENT_TARGET: '10.13'
|
59 |
| - working-directory: packages/next |
| 59 | + |
| 60 | + - name: Upload artifact |
| 61 | + uses: actions/upload-artifact@v2 |
| 62 | + with: |
| 63 | + name: next-swc-binaries |
| 64 | + path: packages/next/native |
| 65 | + |
| 66 | + - name: Clear the cargo caches |
| 67 | + run: | |
| 68 | + cargo install cargo-cache --no-default-features --features ci-autoclean |
| 69 | + cargo-cache |
| 70 | +
|
| 71 | + build-apple-silicon: |
| 72 | + name: stable - aarch64-apple-darwin - node@14 |
| 73 | + runs-on: macos-latest |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v2 |
| 77 | + |
| 78 | + - name: Setup node |
| 79 | + uses: actions/setup-node@v2 |
| 80 | + with: |
| 81 | + node-version: 14 |
| 82 | + |
| 83 | + - name: Install Rust |
| 84 | + uses: actions-rs/toolchain@v1 |
| 85 | + with: |
| 86 | + profile: minimal |
| 87 | + override: true |
| 88 | + toolchain: nightly-2021-03-25 |
| 89 | + target: aarch64-apple-darwin |
| 90 | + |
| 91 | + - name: Install dependencies |
| 92 | + run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000 |
| 93 | + |
| 94 | + - name: Cross build aarch64 |
| 95 | + run: yarn --cwd packages/next build-native --target aarch64-apple-darwin |
| 96 | + |
60 | 97 | - name: Upload artifact
|
61 | 98 | uses: actions/upload-artifact@v2
|
62 | 99 | with:
|
63 | 100 | name: next-swc-binaries
|
64 |
| - path: packages/next/native/next-swc.*.node |
| 101 | + path: packages/next/native |
| 102 | + |
65 | 103 | - name: Clear the cargo caches
|
66 | 104 | run: |
|
67 | 105 | cargo install cargo-cache --no-default-features --features ci-autoclean
|
68 | 106 | cargo-cache
|
| 107 | +
|
69 | 108 | commit:
|
70 |
| - needs: build-native |
| 109 | + needs: [build, build-apple-silicon] |
71 | 110 | runs-on: ubuntu-18.04
|
72 | 111 |
|
73 | 112 | steps:
|
74 | 113 | - uses: actions/checkout@v2
|
| 114 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
75 | 115 | - uses: actions/download-artifact@v2
|
76 | 116 | with:
|
77 | 117 | name: next-swc-binaries
|
78 | 118 | path: packages/next/native
|
| 119 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
79 | 120 | - uses: EndBug/add-and-commit@v7
|
80 | 121 | with:
|
81 | 122 | add: 'packages/next/native --force'
|
82 | 123 | message: 'Build next-swc binaries'
|
| 124 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 125 | + |
| 126 | + check: |
| 127 | + needs: [build, build-apple-silicon] |
| 128 | + runs-on: ubuntu-18.04 |
| 129 | + |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v2 |
| 132 | + if: ${{ github.event_name == 'pull_request' }} |
| 133 | + - uses: actions/download-artifact@v2 |
| 134 | + with: |
| 135 | + name: next-swc-binaries |
| 136 | + path: packages/next/native |
| 137 | + if: ${{ github.event_name == 'pull_request' }} |
| 138 | + - run: git diff --exit-code |
| 139 | + if: ${{ github.event_name == 'pull_request' }} |
| 140 | + |
| 141 | + test: |
| 142 | + runs-on: ubuntu-18.04 |
| 143 | + |
| 144 | + steps: |
| 145 | + - uses: actions/checkout@v2 |
| 146 | + if: ${{ github.event_name == 'pull_request' }} |
| 147 | + - name: Install |
| 148 | + if: ${{ github.event_name == 'pull_request' }} |
| 149 | + uses: actions-rs/toolchain@v1 |
| 150 | + with: |
| 151 | + toolchain: nightly-2021-03-25 |
| 152 | + profile: minimal |
| 153 | + - run: cd packages/next/build/swc && cargo test |
| 154 | + if: ${{ github.event_name == 'pull_request' }} |
0 commit comments