Skip to content

Commit

Permalink
Omit macos-13 runner in PRs (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 23, 2024
1 parent 76d4ec6 commit baac8fa
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
matrix:
os:
- ubuntu-24.04
- macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
- macos-14 # M1. Doesn't match for my Intel Mac, but preferring with the speed.
- windows-latest
runs-on: ${{ matrix.os }}
steps:
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/ci-home.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,31 @@ on:
workflow_dispatch:

jobs:
generate_matrix:
timeout-minutes: 5
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.generator.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Install gh-action-escape
run: curl -fsSL https://raw.githubusercontent.com/kachick/gh-action-escape/main/scripts/install-in-github-action.sh | sh -s v0.2.0
- name: Generate Matrix
id: generator
run: |
go run ./cmd/gen_matrix -event_name '${{ github.event_name }}' | gh-action-escape -name=matrix | tee -a "$GITHUB_OUTPUT"
home-manager:
needs: [generate_matrix]
if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft)
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811

matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
# 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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
matrix:
os:
- ubuntu-24.04
- macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
- macos-14 # M1. Doesn't match for my Intel Mac, but preferring with the speed.
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
Expand Down
48 changes: 48 additions & 0 deletions cmd/gen_matrix/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"log"
)

type Matrix struct {
Os []string `json:"os"`
}

func main() {
eventNameFlag := flag.String("event_name", "", "github.event_name")

flag.Parse()

eventName := *eventNameFlag

if eventName == "" {
flag.Usage()
log.Fatalln("empty event_name is given")
}

matrix := Matrix{
// https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811
Os: []string{
"ubuntu-24.04",
// M1. Doesn't match for my Intel Mac, but preferring with the speed.
"macos-14",
},
}

if eventName != "pull_request" {
matrix.Os = append(matrix.Os,
// Intel. Correct with the architecture. But basically skipping because of it is much slow to complete.
"macos-13",
)
}

bytes, err := json.MarshalIndent(matrix, "", " ")
if err != nil {
log.Fatalln("can't marshal generated JSON matrix")
}

fmt.Println(string(bytes))
}
3 changes: 2 additions & 1 deletion darwin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ So you should manually install followings.

## Limitations

- I only have x86-64 macbook pro, it is much slow in GitHub action macos-13 runner.
- I only have x86-64 macbook pro, it is much slow in GitHub action macos-13 runner.\
So preferring macos-14 runner in several place...
22 changes: 21 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@
edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin;
};
};

aarch64-macOS = {
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
extraSpecialArgs = {
homemade-pkgs = homemade-packages.aarch64-darwin;
edge-pkgs = edge-nixpkgs.legacyPackages.aarch64-darwin;
};
};
in
{
"kachick@linux-gui" = home-manager.lib.homeManagerConfiguration (
Expand Down Expand Up @@ -237,7 +245,19 @@
);

"github-actions@macos-13" = home-manager.lib.homeManagerConfiguration (
x86-macOS
aarch64-macOS
// {
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
modules = [
./home-manager/kachick.nix
{ home.username = "runner"; }
];
}
);

"github-actions@macos-14" = home-manager.lib.homeManagerConfiguration (
aarch64-macOS
// {
# Prefer "kachick" over "common" only here.
# Using values as much as possible as actual values to create a robust CI
Expand Down

0 comments on commit baac8fa

Please sign in to comment.