]> git.lizzy.rs Git - rust.git/blob - .github/workflows/main.yml
Don't require git user to be configured for testing rust
[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         rustup target add x86_64-pc-windows-gnu
81
82     - name: Install AArch64 toolchain and qemu
83       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
84       run: |
85         sudo apt-get update
86         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
87
88     - name: Install s390x toolchain and qemu
89       if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
90       run: |
91         sudo apt-get update
92         sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
93
94     - name: Windows setup
95       if: matrix.os == 'windows-latest'
96       run: git config --global core.autocrlf false
97
98     - name: Use sparse cargo registry
99       run: |
100         cat >> ~/.cargo/config.toml <<EOF
101         [unstable]
102         sparse-registry = true
103         EOF
104
105     - name: Prepare dependencies
106       run: ./y.rs prepare
107
108     - name: Build without unstable features
109       env:
110         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
111       # This is the config rust-lang/rust uses for builds
112       run: ./y.rs build --no-unstable-features
113
114     - name: Build
115       run: ./y.rs build --sysroot none
116
117     - name: Test
118       env:
119         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
120       run: ./y.rs test
121
122     - name: Package prebuilt cg_clif
123       run: tar cvfJ cg_clif.tar.xz dist
124
125     - name: Upload prebuilt cg_clif
126       if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
127       uses: actions/upload-artifact@v3
128       with:
129         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
130         path: cg_clif.tar.xz
131
132     - name: Upload prebuilt cg_clif (cross compile)
133       if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
134       uses: actions/upload-artifact@v3
135       with:
136         name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
137         path: cg_clif.tar.xz