Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimenral rewrite gen_matrix.go with typescript and deno #875

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/scripts/gen_matrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { info } from 'npm:@actions/core@^1.11.1';
import { context } from 'npm:@actions/github@^6.0.0';

import { parseArgs } from 'jsr:@std/cli/parse-args';

const flags = parseArgs(Deno.args, {
string: ['paths'],
});

const { paths: pathLines } = flags;

const paths = pathLines ? pathLines.split(/\r?\n/) : [];

const higherMacOSPossibility = paths.some((path) => path.includes('darwin') || path === 'home-manager/packages.nix');

const fastRunners = ['ubuntu-24.04', 'macos-15'] as const;

const runners = (higherMacOSPossibility || context.eventName !== 'pull_request')
? [...fastRunners, 'macos-13']
: fastRunners;

const matrix = {
os: runners,
} as const;
console.error(context.eventName); // Debug logger
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This outputs undefined, in this use, @actions... toolset cannot be used 🤔

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info(JSON.stringify(matrix, null, ' '));
17 changes: 12 additions & 5 deletions .github/workflows/ci-home.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ jobs:
- name: Get changed paths
run: |
git diff origin/main --name-only | gh-action-escape -name=CHANGED_PATHS | tee --append "$GITHUB_ENV"
- name: Set up Go
uses: actions/setup-go@v5
# - name: Set up Go
# uses: actions/setup-go@v5
# with:
# go-version-file: 'go.mod'
# cache-dependency-path: 'go.sum'
- uses: denoland/setup-deno@v1
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
deno-version: '1.44.3' # selfup {"extract":"\\d[^']+","replacer":["bash","-c","deno --version | head -n 1 | cut -d ' ' -f 2"]}
# - name: Generate Matrix
# id: generator
# run: |
# go run ./cmd/gen_matrix -event_name '${{ github.event_name }}' -paths "$CHANGED_PATHS" | gh-action-escape -name=matrix | tee -a "$GITHUB_OUTPUT"
- name: Generate Matrix
id: generator
run: |
go run ./cmd/gen_matrix -event_name '${{ github.event_name }}' -paths "$CHANGED_PATHS" | gh-action-escape -name=matrix | tee -a "$GITHUB_OUTPUT"
deno run ./.github/scripts/gen_matrix.ts -paths "$CHANGED_PATHS" | 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)
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"kdl-org.kdl",
"JohnnyMorganz.stylua",
"davidanson.vscode-markdownlint",
"TheNuProjectContributors.vscode-nushell-lang"
"TheNuProjectContributors.vscode-nushell-lang",
"denoland.vscode-deno"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"build.buildFlags": ["-tags=linux,windows,darwin"]
},
"stylua.searchBinaryInPATH": true,
"shellformat.useEditorConfig": true
"shellformat.useEditorConfig": true,
"deno.enable": true
}
6 changes: 5 additions & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
"toml": {
},
"typescript": {
"quoteStyle": "preferSingle"
},
"excludes": [
".git",
".direnv",
Expand All @@ -23,6 +26,7 @@
"https://plugins.dprint.dev/markdown-0.17.8.wasm",
"https://plugins.dprint.dev/toml-0.6.3.wasm",
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm",
"https://plugins.dprint.dev/kachick/kdl-0.1.0.wasm"
"https://plugins.dprint.dev/kachick/kdl-0.1.0.wasm",
"https://plugins.dprint.dev/typescript-0.93.0.wasm"
]
}
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
go_1_23
goreleaser
trivy

deno
])
++ (with edge-pkgs; [
nixd
Expand Down