Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See [Testing Farm onboarding guide](https://docs.testing-farm.io/Testing%20Farm/
|------------|-------------|---------------|
| `api_key` | Testing farm API key | empty, **required from user** |
| `api_url` | Testing farm API server url | https://api.dev.testing-farm.io/v0.1 |
| `tf_scope` | Define the scope of Testing Farm. Possible options are 'public' or 'private' | public |
| `tf_scope` | **Deprecated**, this input is no longer used. `tf_scope` is now automatically detected based on the provided `api_key`. ~Define the scope of Testing Farm. Possible options are 'public' or 'private'~ | public |

### Tmt Metadata

Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ inputs:
tf_scope:
description: 'Defines the scope of Testing Farm. Possible options are public and private'
required: false
deprecationMessage: 'This input is no longer used. tf_scope is now automatically detected based on the provided api_key. Will be removed in the future.'
default: 'public'

# Tmt Metadata
Expand Down
5 changes: 2 additions & 3 deletions dist/action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/action.js.map

Large diffs are not rendered by default.

30 changes: 25 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions dist/schema/input.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/schema/input.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/schema/input.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@octokit/types": "16.0.0",
"date-fns": "4.1.0",
"issue-metadata": "0.2.4",
"testing-farm": "1.11.0",
"testing-farm": "1.12.0",
"zod": "4.1.12"
},
"devDependencies": {
Expand Down
5 changes: 1 addition & 4 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { composeStatusDescription, getSummary } from './util';
import {
pipelineSettingsSchema,
envSettingsSchema,
tfScopeSchema,
timeoutSchema,
tmtArtifactsInputSchema,
tmtArtifactsSchema,
Expand Down Expand Up @@ -46,9 +45,7 @@ async function action(pr: PullRequest): Promise<void> {
);

// Set artifacts url
const tfScopeParsed = tfScopeSchema.safeParse(getInput('tf_scope'));
const tfScope = tfScopeParsed.success ? tfScopeParsed.data : 'public';

const tfScope = (await api.whoami()).token.ranch;
const tfUrl =
tfScope === 'public'
? 'https://artifacts.dev.testing-farm.io'
Expand Down
2 changes: 0 additions & 2 deletions src/schema/input.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { NewRequest } from 'testing-farm';
import { z } from 'zod';

export const tfScopeSchema = z.enum(['public', 'private']);

// Parse string input into object of key-value pairs
// input: 'REPO_URL=GITHUB_SERVER_URL/GITHUB_REPOSITORY;REPO_NAME=GITHUB_REPOSITORY'
// output: { REPO_URL: 'GITHUB_SERVER_URL/GITHUB_REPOSITORY', REPO_NAME: 'GITHUB_REPOSITORY' }
Expand Down
14 changes: 14 additions & 0 deletions tests/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function setDefaultInputs() {
const mocks = vi.hoisted(() => {
return {
request: vi.fn(),
whoami: vi.fn(),
newRequest: vi.fn(),
unsafeNewRequest: vi.fn(),
requestDetails: vi.fn(),
Expand All @@ -82,6 +83,7 @@ vi.mock('@octokit/core', () => {
// Mock testing-farm module
vi.mock('testing-farm', async () => {
const TestingFarmAPI = vi.fn(() => ({
whoami: mocks.whoami,
newRequest: mocks.newRequest,
unsafeNewRequest: mocks.unsafeNewRequest,
requestDetails: mocks.requestDetails,
Expand Down Expand Up @@ -159,6 +161,12 @@ describe('Integration tests - action.ts', () => {
vi.stubEnv('GITHUB_REPOSITORY', 'sclorg/testing-farm-as-github-action');
vi.stubEnv('INPUT_GITHUB_TOKEN', 'mock-token');

vi.mocked(mocks.whoami).mockResolvedValue({
token: {
ranch: 'public',
},
});

// Mock GitHub API
vi.mocked(mocks.request).mockImplementation(path => {
switch (path) {
Expand Down Expand Up @@ -1048,6 +1056,12 @@ describe('Integration tests - action.ts', () => {
vi.stubEnv('INPUT_PR_NUMBER', '1');
vi.stubEnv('INPUT_COMMIT_SHA', 'd20d0c37d634a5303fa1e02edc9ea281897ba01a');

vi.mocked(mocks.whoami).mockResolvedValue({
token: {
ranch: 'private',
},
});

// Mock Testing Farm API
vi.mocked(mocks.newRequest).mockImplementation(
async (_request: NewRequest, _strict: boolean) => {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2574,21 +2574,21 @@ __metadata:
date-fns: "npm:4.1.0"
issue-metadata: "npm:0.2.4"
prettier: "npm:3.6.2"
testing-farm: "npm:1.11.0"
testing-farm: "npm:1.12.0"
ts-node: "npm:10.9.2"
typescript: "npm:5.9.3"
vitest: "npm:3.2.4"
zod: "npm:4.1.12"
languageName: unknown
linkType: soft

"testing-farm@npm:1.11.0":
version: 1.11.0
resolution: "testing-farm@npm:1.11.0"
"testing-farm@npm:1.12.0":
version: 1.12.0
resolution: "testing-farm@npm:1.12.0"
dependencies:
axios: "npm:1.13.2"
zod: "npm:4.1.12"
checksum: 10/2f91a5e3428ff71400aa009deff405479fc1b1cc8dd42fa5be1f8d7176e03c226f01457521efd183132367cf2f7004e4b069ceef661833c47df12ab5c2ba94e8
checksum: 10/7c421f2cd3bc5d05e7fbe899bffa03420a7a2f3c48749217b134aaf61a4f56f8d93c0c9dede891c3153cc09d72bf3b2416285bc4282a84e89a3fdbcc2642f813
languageName: node
linkType: hard

Expand Down
Loading