]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Auto merge of #100942 - ehuss:update-cargo, r=ehuss
[rust.git] / compiler / rustc_codegen_cranelift / .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
23   build:
24     runs-on: ${{ matrix.os }}
25     timeout-minutes: 60
26
27     strategy:
28       fail-fast: false
29       matrix:
30         include:
31           - os: ubuntu-latest
32           - os: macos-latest
33           # cross-compile from Linux to Windows using mingw
34           - os: ubuntu-latest
35             env:
36               TARGET_TRIPLE: x86_64-pc-windows-gnu
37           - os: ubuntu-latest
38             env:
39               TARGET_TRIPLE: aarch64-unknown-linux-gnu
40
41     steps:
42     - uses: actions/checkout@v3
43
44     - name: Cache cargo installed crates
45       uses: actions/cache@v2
46       with:
47         path: ~/.cargo/bin
48         key: ${{ runner.os }}-cargo-installed-crates
49
50     - name: Cache cargo registry and index
51       uses: actions/cache@v2
52       with:
53         path: |
54             ~/.cargo/registry
55             ~/.cargo/git
56         key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
57
58     - name: Cache cargo target dir
59       uses: actions/cache@v2
60       with:
61         path: target
62         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
63
64     - name: Install MinGW toolchain and wine
65       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
66       run: |
67         sudo apt-get update
68         sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
69         rustup target add x86_64-pc-windows-gnu
70
71     - name: Install AArch64 toolchain and qemu
72       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
73       run: |
74         sudo apt-get update
75         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
76
77     - name: Prepare dependencies
78       run: |
79         git config --global user.email "user@example.com"
80         git config --global user.name "User"
81         ./y.rs prepare
82
83     - name: Build without unstable features
84       env:
85         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
86       # This is the config rust-lang/rust uses for builds
87       run: ./y.rs build --no-unstable-features
88
89     - name: Build
90       run: ./y.rs build --sysroot none
91
92     - name: Test
93       env:
94         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
95       run: |
96         # Enable backtraces for easier debugging
97         export RUST_BACKTRACE=1
98
99         # Reduce amount of benchmark runs as they are slow
100         export COMPILE_RUNS=2
101         export RUN_RUNS=2
102
103         # Enable extra checks
104         export CG_CLIF_ENABLE_VERIFIER=1
105
106         ./test.sh
107
108     - name: Package prebuilt cg_clif
109       run: tar cvfJ cg_clif.tar.xz build
110
111     - name: Upload prebuilt cg_clif
112       if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
113       uses: actions/upload-artifact@v2
114       with:
115         name: cg_clif-${{ runner.os }}
116         path: cg_clif.tar.xz
117
118     - name: Upload prebuilt cg_clif (cross compile)
119       if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
120       uses: actions/upload-artifact@v2
121       with:
122         name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
123         path: cg_clif.tar.xz
124
125   build_windows:
126     runs-on: windows-latest
127     timeout-minutes: 60
128
129     steps:
130     - uses: actions/checkout@v3
131
132     #- name: Cache cargo installed crates
133     #  uses: actions/cache@v2
134     #  with:
135     #    path: ~/.cargo/bin
136     #    key: ${{ runner.os }}-cargo-installed-crates
137
138     #- name: Cache cargo registry and index
139     #  uses: actions/cache@v2
140     #  with:
141     #    path: |
142     #        ~/.cargo/registry
143     #        ~/.cargo/git
144     #    key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
145
146     #- name: Cache cargo target dir
147     #  uses: actions/cache@v2
148     #  with:
149     #    path: target
150     #    key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
151
152     - name: Prepare dependencies
153       run: |
154         git config --global user.email "user@example.com"
155         git config --global user.name "User"
156         git config --global core.autocrlf false
157         rustup set default-host x86_64-pc-windows-gnu
158         rustc y.rs -o y.exe -g
159         ./y.exe prepare
160
161     - name: Build
162       #name: Test
163       run: |
164         # Enable backtraces for easier debugging
165         #export RUST_BACKTRACE=1
166
167         # Reduce amount of benchmark runs as they are slow
168         #export COMPILE_RUNS=2
169         #export RUN_RUNS=2
170
171         # Enable extra checks
172         #export CG_CLIF_ENABLE_VERIFIER=1
173
174         ./y.exe build
175
176     - name: Package prebuilt cg_clif
177       # don't use compression as xzip isn't supported by tar on windows and bzip2 hangs
178       run: tar cvf cg_clif.tar build
179
180     - name: Upload prebuilt cg_clif
181       uses: actions/upload-artifact@v2
182       with:
183         name: cg_clif-${{ runner.os }}
184         path: cg_clif.tar