Skip to content

Commit 647c675

Browse files
committed
Omit macos-13 runner in PRs (#696)
1 parent 76d4ec6 commit 647c675

File tree

6 files changed

+92
-8
lines changed

6 files changed

+92
-8
lines changed

.github/workflows/ci-go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
matrix:
2828
os:
2929
- ubuntu-24.04
30-
- macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
30+
- macos-14 # M1. Doesn't match for my Intel Mac, but preferring with the speed.
3131
- windows-latest
3232
runs-on: ${{ matrix.os }}
3333
steps:

.github/workflows/ci-home.yml

+20-5
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,31 @@ on:
2222
workflow_dispatch:
2323

2424
jobs:
25+
generate_matrix:
26+
timeout-minutes: 5
27+
runs-on: ubuntu-24.04
28+
outputs:
29+
matrix: ${{ steps.generator.outputs.matrix }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version-file: 'go.mod'
36+
cache-dependency-path: 'go.sum'
37+
- name: Install gh-action-escape
38+
run: curl -fsSL https://raw.githubusercontent.com/kachick/gh-action-escape/main/scripts/install-in-github-action.sh | sh -s v0.2.0
39+
- name: Generate Matrix
40+
id: generator
41+
run: |
42+
go run ./cmd/gen_matrix -event_name '${{ github.event_name }}' | gh-action-escape -name=matrix | tee -a "$GITHUB_OUTPUT"
2543
home-manager:
44+
needs: [generate_matrix]
2645
if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft)
2746
timeout-minutes: 30
2847
strategy:
2948
fail-fast: false
30-
matrix:
31-
os:
32-
- ubuntu-24.04
33-
- macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
34-
49+
matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix) }}
3550
runs-on: ${{ matrix.os }}
3651
steps:
3752
# Do not use DeterminateSystems/magic-nix-cache-action for home workflow, it always faced to GitHub rate limit because of home depends on many packages

.github/workflows/ci-nix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
matrix:
2929
os:
3030
- ubuntu-24.04
31-
- macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
31+
- macos-14 # M1. Doesn't match for my Intel Mac, but preferring with the speed.
3232
runs-on: ${{ matrix.os }}
3333
timeout-minutes: 30
3434
steps:

cmd/gen_matrix/main.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"flag"
6+
"fmt"
7+
"log"
8+
)
9+
10+
type Matrix struct {
11+
Os []string `json:"os"`
12+
}
13+
14+
func main() {
15+
eventNameFlag := flag.String("event_name", "", "github.event_name")
16+
17+
flag.Parse()
18+
19+
eventName := *eventNameFlag
20+
21+
if eventName == "" {
22+
flag.Usage()
23+
log.Fatalln("empty event_name is given")
24+
}
25+
26+
matrix := Matrix{
27+
// https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
28+
Os: []string{
29+
"ubuntu-24.04",
30+
// M1. Doesn't match for my Intel Mac, but preferring with the speed.
31+
"macos-14",
32+
},
33+
}
34+
35+
if eventName != "pull_request" {
36+
matrix.Os = append(matrix.Os,
37+
// Intel. Correct with the architecture. But basically skipping because of it is much slow to complete.
38+
"macos-13",
39+
)
40+
}
41+
42+
bytes, err := json.MarshalIndent(matrix, "", " ")
43+
if err != nil {
44+
log.Fatalln("can't marshal generated JSON matrix")
45+
}
46+
47+
fmt.Println(string(bytes))
48+
}

darwin/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ So you should manually install followings.
1212

1313
## Limitations
1414

15-
- I only have x86-64 macbook pro, it is much slow in GitHub action macos-13 runner.
15+
- I only have x86-64 macbook pro, it is much slow in GitHub action macos-13 runner.\
16+
So preferring macos-14 runner in several place...

flake.nix

+20
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@
196196
edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin;
197197
};
198198
};
199+
200+
aarch64-macOS = {
201+
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
202+
extraSpecialArgs = {
203+
homemade-pkgs = homemade-packages.aarch64-darwin;
204+
edge-pkgs = edge-nixpkgs.legacyPackages.aarch64-darwin;
205+
};
206+
};
199207
in
200208
{
201209
"kachick@linux-gui" = home-manager.lib.homeManagerConfiguration (
@@ -248,6 +256,18 @@
248256
}
249257
);
250258

259+
"github-actions@macos-14" = home-manager.lib.homeManagerConfiguration (
260+
aarch64-macOS
261+
// {
262+
# Prefer "kachick" over "common" only here.
263+
# Using values as much as possible as actual values to create a robust CI
264+
modules = [
265+
./home-manager/kachick.nix
266+
{ home.username = "runner"; }
267+
];
268+
}
269+
);
270+
251271
"user@linux-cui" = home-manager.lib.homeManagerConfiguration (
252272
x86-Linux
253273
// {

0 commit comments

Comments
 (0)