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

Make this a TypeScript Action #27

Merged
merged 3 commits into from
May 23, 2024
Merged
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
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
73 changes: 73 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"plugins": ["@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"settings": {
"import/resolver": {
"typescript": {}
}
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "no-public"
}
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true
}
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true
}
}
4 changes: 2 additions & 2 deletions .github/workflows/buffered-nixpkgs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
workflow_dispatch:
schedule:
- cron: '30 5 * * 2'
- cron: "30 5 * * 2"

jobs:
rolling:
name: Buffered mirror of branch ${{ matrix.repo }}#${{ matrix.branch }}
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
pull_request:
push:
branches: [main]

jobs:
build-check-typescript:
name: Build, check, and test the TypeScript Action
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Install pnpm dependencies
run: nix develop --command pnpm install
- name: Check prettier formatting
run: nix develop --command pnpm run format
- name: Run ESLint
run: nix develop --command pnpm run lint
- name: Run Vitest test suite
run: nix develop --command pnpm test
- name: Build using tsup
run: nix develop --command pnpm run build
- name: Package using ncc
run: nix develop --command pnpm run package
- name: git status
run: git status --porcelain=v1
- name: Ensure no unstaged changes
run: git diff --exit-code
6 changes: 3 additions & 3 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
workflow_dispatch:
schedule:
- cron: '30 5,17 * * *'
- cron: "30 5,17 * * *"

jobs:
mirror_tags:
name: Tag ${{ matrix.repo }}
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
tag: ${{ steps.tagfetch.outputs.tag }}
log-directives: flakehub_push=trace
logger: pretty

rolling:
name: Branch ${{ matrix.repo }}#${{ matrix.branch }}
strategy:
Expand Down
53 changes: 12 additions & 41 deletions .github/workflows/nixpkgs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "Publish every Git push to NixOS release branches to FlakeHub. nixos-unstable is 0.1.x, and nixos-yy.mm is 0.yymm.x."
run-name: Mirror Nixpkgs ${{ inputs.release_branch }}
run-name: Mirror Nixpkgs ${{ inputs.release-branch }}
on:
workflow_dispatch:
inputs:
release_branch:
release-branch:
description: "The release branch to publish to FlakeHub"
type: "string"
required: true
Expand All @@ -15,59 +15,30 @@ jobs:
id-token: "write"
contents: "read"
steps:
- uses: actions/github-script@v6
id: split
env:
RELEASE_BRANCH: "${{ inputs.release_branch }}"
with:
script: |
"use strict";
const ref = process.env['RELEASE_BRANCH'];
if (!ref) {
console.log("ref is undefined in context:", context);
process.exit(1);
}
console.log(`Calculating the minor version for ${ref}`);
let regex = new RegExp(/^nixos-(?<version>([0-9]+\.[0-9]+)|unstable)$/);
let match = regex.exec(ref);
if (match && match.groups) {
const versionPart = match.groups.version;
if (versionPart) {
const minorVersion = versionPart == "unstable" ? "1" : versionPart.replace('.', '');
console.log(`Minor version part: ${minorVersion}`);
core.setOutput("minorVersion", minorVersion);
}
else {
console.log(`version part is undefined in matches:`, match.groups);
process.exit(1);
}
}
else {
console.log(`Branch didn't match our publishable regex.`);
process.exit();
}
- name: Determine minor version
id: minor-version
run: node "$GITHUB_ACTION_PATH/dist/index.js"

- uses: "actions/checkout@v3"
if: steps.split.outputs.minorVersion
if: steps.minor-version.outputs.minorVersion
with:
repository: "NixOS/nixpkgs"
ref: ${{ inputs.release_branch }}
ref: ${{ inputs.release-branch }}


- uses: "DeterminateSystems/nix-installer-action@main"
if: steps.split.outputs.minorVersion
if: steps.minor-version.outputs.minorVersion

- uses: DeterminateSystems/magic-nix-cache-action@main
if: steps.split.outputs.minorVersion
if: steps.minor-version.outputs.minorVersion

- uses: "DeterminateSystems/flakehub-push@main"
if: steps.split.outputs.minorVersion
if: steps.minor-version.outputs.minorVersion
with:
name: "NixOS/nixpkgs"
repository: "NixOS/nixpkgs"
rolling: true
visibility: "public"
rolling-minor: "${{ steps.split.outputs.minorVersion }}"
rolling-minor: "${{ steps.minor-version.outputs.minorVersion }}"
mirror: true
log-directives: flakehub_push=trace
logger: pretty
2 changes: 1 addition & 1 deletion .github/workflows/rolling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
repository: ${{ inputs.repo }}
ref: ${{ inputs.branch }}

- uses: "DeterminateSystems/nix-installer-action@main"
- uses: "DeterminateSystems/magic-nix-cache-action@main"
- uses: "DeterminateSystems/flakehub-push@main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tagged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
repository: ${{ inputs.repo }}
ref: ${{ inputs.tag }}

- uses: "DeterminateSystems/nix-installer-action@main"
- uses: "DeterminateSystems/magic-nix-cache-action@main"
- uses: "DeterminateSystems/flakehub-push@main"
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
workflow_dispatch:

jobs:
mirror_tags:
name: Tag ${{ matrix.repo }} (Test)
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
tag: ${{ steps.tagfetch.outputs.tag }}
log-directives: flakehub_push=trace
logger: pretty

rolling:
name: Branch ${{ matrix.repo }}#${{ matrix.branch }}
strategy:
Expand All @@ -48,7 +48,6 @@ jobs:
- repo: grahamc/test7
branch: main


runs-on: ubuntu-latest
permissions:
contents: write # In order to upload artifacts to GitHub releases
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
pnpm-lock.yaml
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare function getRollingMinor(branch: string): string;

export { getRollingMinor };
Loading
Loading