Skip to content

Commit

Permalink
Prefer macos-14 runner again except PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 23, 2024
1 parent 76d4ec6 commit a63d2b3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci-home.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,30 @@ on:
workflow_dispatch:

jobs:
generate_matrix:
timeout-minutes: 5
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.generator.outputs.matrix }}
steps:
- 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: ${{ 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
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 for much faster.
"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))
}

0 comments on commit a63d2b3

Please sign in to comment.