]> git.lizzy.rs Git - rust.git/blob - .github/workflows/main.yml
Start running regex-shootout-regex-dna on Windows again
[rust.git] / .github / workflows / main.yml
1 name: CI
2
3 on:
4   - push
5   - pull_request
6
7 jobs:
8   rustfmt:
9     runs-on: ubuntu-latest
10     timeout-minutes: 10
11
12     steps:
13     - uses: actions/checkout@v3
14
15     - name: Install rustfmt
16       run: |
17         rustup component add rustfmt
18
19     - name: Rustfmt
20       run: |
21         cargo fmt --check
22         rustfmt --check build_system/mod.rs
23
24   build:
25     runs-on: ${{ matrix.os }}
26     timeout-minutes: 60
27
28     strategy:
29       fail-fast: false
30       matrix:
31         include:
32           - os: ubuntu-20.04 # FIXME switch to ubuntu-22.04 once #1303 is fixed
33             env:
34               TARGET_TRIPLE: x86_64-unknown-linux-gnu
35           - os: macos-latest
36             env:
37               TARGET_TRIPLE: x86_64-apple-darwin
38           # cross-compile from Linux to Windows using mingw
39           - os: ubuntu-latest
40             env:
41               TARGET_TRIPLE: x86_64-pc-windows-gnu
42           - os: ubuntu-latest
43             env:
44               TARGET_TRIPLE: aarch64-unknown-linux-gnu
45           # s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default
46           - os: ubuntu-latest
47             env:
48               TARGET_TRIPLE: s390x-unknown-linux-gnu
49
50     steps:
51     - uses: actions/checkout@v3
52
53     - name: Cache cargo installed crates
54       uses: actions/cache@v3
55       with:
56         path: ~/.cargo/bin
57         key: ${{ runner.os }}-cargo-installed-crates
58
59     - name: Cache cargo registry and index
60       uses: actions/cache@v3
61       with:
62         path: |
63             ~/.cargo/registry
64             ~/.cargo/git
65         key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
66
67     - name: Cache cargo target dir
68       uses: actions/cache@v3
69       with:
70         path: build/cg_clif
71         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
72
73     - name: Install MinGW toolchain and wine
74       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
75       run: |
76         sudo apt-get update
77         sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
78         rustup target add x86_64-pc-windows-gnu
79
80     - name: Install AArch64 toolchain and qemu
81       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
82       run: |
83         sudo apt-get update
84         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
85
86     - name: Install s390x toolchain and qemu
87       if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
88       run: |
89         sudo apt-get update
90         sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
91
92     - name: Prepare dependencies
93       run: ./y.rs prepare
94
95     - name: Build without unstable features
96       env:
97         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
98       # This is the config rust-lang/rust uses for builds
99       run: ./y.rs build --no-unstable-features
100
101     - name: Build
102       run: ./y.rs build --sysroot none
103
104     - name: Test
105       env:
106         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
107       run: ./y.rs test
108
109     - name: Package prebuilt cg_clif
110       run: tar cvfJ cg_clif.tar.xz dist
111
112     - name: Upload prebuilt cg_clif
113       if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
114       uses: actions/upload-artifact@v3
115       with:
116         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
117         path: cg_clif.tar.xz
118
119     - name: Upload prebuilt cg_clif (cross compile)
120       if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
121       uses: actions/upload-artifact@v3
122       with:
123         name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
124         path: cg_clif.tar.xz
125
126   windows:
127     runs-on: ${{ matrix.os }}
128     timeout-minutes: 60
129
130     strategy:
131       fail-fast: false
132       matrix:
133         include:
134           # Native Windows build with MSVC
135           - os: windows-latest
136             env:
137               TARGET_TRIPLE: x86_64-pc-windows-msvc
138           # cross-compile from Windows to Windows MinGW
139           - os: windows-latest
140             env:
141               TARGET_TRIPLE: x86_64-pc-windows-gnu
142
143     steps:
144     - uses: actions/checkout@v3
145
146     - name: Cache cargo installed crates
147       uses: actions/cache@v3
148       with:
149         path: ~/.cargo/bin
150         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-installed-crates
151
152     - name: Cache cargo registry and index
153       uses: actions/cache@v3
154       with:
155         path: |
156             ~/.cargo/registry
157             ~/.cargo/git
158         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
159
160     - name: Cache cargo target dir
161       uses: actions/cache@v3
162       with:
163         path: build/cg_clif
164         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
165
166     - name: Set MinGW as the default toolchain
167       if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
168       run: rustup set default-host x86_64-pc-windows-gnu
169
170     - name: Prepare dependencies
171       run: |
172         git config --global core.autocrlf false
173         rustc y.rs -o y.exe -g
174         ./y.exe prepare
175
176     - name: Build without unstable features
177       env:
178         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
179       # This is the config rust-lang/rust uses for builds
180       run: ./y.exe build --no-unstable-features
181
182     - name: Build
183       run: ./y.exe build --sysroot none
184
185     - name: Test
186       run: ./y.exe test
187
188     - name: Package prebuilt cg_clif
189       # don't use compression as xzip isn't supported by tar on windows and bzip2 hangs
190       run: tar cvf cg_clif.tar dist
191
192     - name: Upload prebuilt cg_clif
193       uses: actions/upload-artifact@v3
194       with:
195         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
196         path: cg_clif.tar