]> git.lizzy.rs Git - rust.git/blob - .github/workflows/main.yml
Build rtstartup for MinGW from scratch
[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     defaults:
29       run:
30         shell: bash
31
32     strategy:
33       fail-fast: false
34       matrix:
35         include:
36           - os: ubuntu-20.04 # FIXME switch to ubuntu-22.04 once #1303 is fixed
37             env:
38               TARGET_TRIPLE: x86_64-unknown-linux-gnu
39           - os: macos-latest
40             env:
41               TARGET_TRIPLE: x86_64-apple-darwin
42           # cross-compile from Linux to Windows using mingw
43           - os: ubuntu-latest
44             env:
45               TARGET_TRIPLE: x86_64-pc-windows-gnu
46           - os: ubuntu-latest
47             env:
48               TARGET_TRIPLE: aarch64-unknown-linux-gnu
49           # s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default
50           - os: ubuntu-latest
51             env:
52               TARGET_TRIPLE: s390x-unknown-linux-gnu
53           # Native Windows build with MSVC
54           - os: windows-latest
55             env:
56               TARGET_TRIPLE: x86_64-pc-windows-msvc
57           # cross-compile from Windows to Windows MinGW
58           - os: windows-latest
59             env:
60               TARGET_TRIPLE: x86_64-pc-windows-gnu
61
62     steps:
63     - uses: actions/checkout@v3
64
65     - name: Cache cargo target dir
66       uses: actions/cache@v3
67       with:
68         path: build/cg_clif
69         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
70
71     - name: Set MinGW as the default toolchain
72       if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
73       run: rustup set default-host x86_64-pc-windows-gnu
74
75     - name: Install MinGW toolchain and wine
76       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
77       run: |
78         sudo apt-get update
79         sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
80
81     - name: Install AArch64 toolchain and qemu
82       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
83       run: |
84         sudo apt-get update
85         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
86
87     - name: Install s390x toolchain and qemu
88       if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
89       run: |
90         sudo apt-get update
91         sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
92
93     - name: Use sparse cargo registry
94       run: |
95         cat >> ~/.cargo/config.toml <<EOF
96         [unstable]
97         sparse-registry = true
98         EOF
99
100     - name: Prepare dependencies
101       run: ./y.rs prepare
102
103     - name: Build without unstable features
104       env:
105         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
106       # This is the config rust-lang/rust uses for builds
107       run: ./y.rs build --no-unstable-features
108
109     - name: Build
110       run: ./y.rs build --sysroot none
111
112     - name: Test
113       env:
114         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
115       run: ./y.rs test
116
117     - name: Package prebuilt cg_clif
118       run: tar cvfJ cg_clif.tar.xz dist
119
120     - name: Upload prebuilt cg_clif
121       if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
122       uses: actions/upload-artifact@v3
123       with:
124         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
125         path: cg_clif.tar.xz
126
127     - name: Upload prebuilt cg_clif (cross compile)
128       if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
129       uses: actions/upload-artifact@v3
130       with:
131         name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
132         path: cg_clif.tar.xz