Skip to content

Commit e735206

Browse files
committed
Unify Windows and non-Windows CI
1 parent 280fb29 commit e735206

File tree

1 file changed

+25
-77
lines changed

1 file changed

+25
-77
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
runs-on: ${{ matrix.os }}
2626
timeout-minutes: 60
2727

28+
defaults:
29+
run:
30+
shell: bash
31+
2832
strategy:
2933
fail-fast: false
3034
matrix:
@@ -46,6 +50,14 @@ jobs:
4650
- os: ubuntu-latest
4751
env:
4852
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
4961

5062
steps:
5163
- uses: actions/checkout@v3
@@ -54,21 +66,25 @@ jobs:
5466
uses: actions/cache@v3
5567
with:
5668
path: ~/.cargo/bin
57-
key: ${{ runner.os }}-cargo-installed-crates
69+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-installed-crates
5870

5971
- name: Cache cargo registry and index
6072
uses: actions/cache@v3
6173
with:
6274
path: |
6375
~/.cargo/registry
6476
~/.cargo/git
65-
key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
77+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
6678

6779
- name: Cache cargo target dir
6880
uses: actions/cache@v3
6981
with:
7082
path: build/cg_clif
71-
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
83+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
84+
85+
- name: Set MinGW as the default toolchain
86+
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
87+
run: rustup set default-host x86_64-pc-windows-gnu
7288

7389
- name: Install MinGW toolchain and wine
7490
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
@@ -89,6 +105,10 @@ jobs:
89105
sudo apt-get update
90106
sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
91107
108+
- name: Windows setup
109+
if: matrix.os == 'windows-latest'
110+
run: git config --global core.autocrlf false
111+
92112
- name: Prepare dependencies
93113
run: ./y.rs prepare
94114

@@ -110,87 +130,15 @@ jobs:
110130
run: tar cvfJ cg_clif.tar.xz dist
111131

112132
- name: Upload prebuilt cg_clif
113-
if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
133+
if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
114134
uses: actions/upload-artifact@v3
115135
with:
116136
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
117137
path: cg_clif.tar.xz
118138

119139
- name: Upload prebuilt cg_clif (cross compile)
120-
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
140+
if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
121141
uses: actions/upload-artifact@v3
122142
with:
123143
name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
124144
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

0 commit comments

Comments
 (0)