Skip to content

Commit

Permalink
ci: jsr registry test
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Dec 8, 2024
1 parent bd8e499 commit 9de686f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,36 @@ jobs:
id: run_bun
run: |
bun --version
setup-bun-jsr-registry:
name: setup-bun jsr registry (${{ matrix.os }})
runs-on: ${{ matrix.os }}
continue-on-error: true
needs: [remove-cache, tests]
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: ./
id: setup_bun
with:
registries: |
[
{
"url": "https://npm.jsr.io"
"scope": "@jsr"
}
]
- name: Run Bun
id: run_bun
run: |
bun add @luca/runtime-detector
6 changes: 4 additions & 2 deletions src/bunfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { info } from "@actions/core";
export type Registry = {
url: string;
scope: string;
token: string;
token?: string;
};

enum FieldType {
Expand Down Expand Up @@ -40,7 +40,9 @@ export function createField(registry: Registry): Field {
if (url && owner) {
return {
type: FieldType.INSTALL_WITH_SCOPE,
value: `'${owner}' = { token = "${token}", url = "${url}" }`,
value: `'${owner}' = { url = "${url}"${
token ? `, token = "${token}"` : ""
} }`,
};
}

Expand Down
10 changes: 5 additions & 5 deletions tests/bunfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("writeBunfig", () => {

const expectedContents = [
"[install.scopes]",
'\'@foo-bar\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
'\'@foo-bar\' = { url = "https://npm.pkg.github.com/", token = "$BUN_AUTH_TOKEN" }',
"",
];

Expand Down Expand Up @@ -97,7 +97,7 @@ describe("writeBunfig", () => {
"[install.cache]",
"disable = true",
"[install.scopes]",
'\'@foo-bar\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
'\'@foo-bar\' = { url = "https://npm.pkg.github.com/", token = "$BUN_AUTH_TOKEN" }',
"",
];

Expand Down Expand Up @@ -130,7 +130,7 @@ describe("writeBunfig", () => {
"optional = true",
"",
"[install.scopes]",
'\'@foo-bar\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
'\'@foo-bar\' = { url = "https://npm.pkg.github.com/", token = "$BUN_AUTH_TOKEN" }',
'\'@bla-ble\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
"",
"[install.cache]",
Expand Down Expand Up @@ -167,7 +167,7 @@ describe("writeBunfig", () => {
"optional = true",
"",
"[install.scopes]",
'\'@foo-bar\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
'\'@foo-bar\' = { url = "https://npm.pkg.github.com/", token = "$BUN_AUTH_TOKEN" }',
'\'@bla-ble\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
"",
"[install.cache]",
Expand Down Expand Up @@ -210,7 +210,7 @@ describe("writeBunfig", () => {
"optional = true",
"",
"[install.scopes]",
'\'@foo-bar\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
'\'@foo-bar\' = { url = "https://npm.pkg.github.com/", token = "$BUN_AUTH_TOKEN" }',
'\'@bla-ble\' = { token = "$BUN_AUTH_TOKEN", url = "https://npm.pkg.github.com/" }',
"",
"[install.cache]",
Expand Down

0 comments on commit 9de686f

Please sign in to comment.