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 .github/workflows/internal_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18.15.0
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
env:
Expand Down
22 changes: 2 additions & 20 deletions .github/workflows/test/frontend_runtime_application_pr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { getWorkflowConfig, runWorkflow } from 'tests/utils/setup';
import {
getTestResult,
getTestResults,
setInputs,
setSecrets,
} from 'tests/utils/helpers';
import mockPackageJson from 'tests/package.json';

let mockGithub: MockGithub;

Expand All @@ -26,13 +24,7 @@ afterEach(async () => {
test('validate inputs and secrets', async () => {
const act = new Act(mockGithub.repo.getPath(repoName));
const mockSecrets = ['CHROMATIC_PROJECT_TOKEN'];
const mockInputs = {
magic_url_route: 'magic_url_route_test',
};

setSecrets({ act, mockSecrets });
setInputs({ act, mockInputs });

act.setInput('use_chromatic', 'true');

const results = await runWorkflow({ act, repoName, mockGithub });
Expand All @@ -42,16 +34,6 @@ test('validate inputs and secrets', async () => {

expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`);

// magic_url
const magic_url_inputs = getTestResult({ results, name: 'magic_url_inputs' });

expect(magic_url_inputs.output).toContain(
`migration=${mockPackageJson.config.migration}`
);
expect(magic_url_inputs.output).toContain(
`magic_url_route=${mockInputs.magic_url_route}`
);

// pr_comment
const pr_comment_inputs = getTestResult({
results,
Expand All @@ -70,10 +52,10 @@ test('default flow', async () => {

const jobs_found = getTestResults({
results,
names: ['pr_comment', 'migration_number', 'validate', 'magic_url'],
names: ['pr_comment', 'migration_number', 'validate'],
});

expect(jobs_found.length).toEqual(4);
expect(jobs_found.length).toEqual(3);
});

test('when use_validate is false', async () => {
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/test/frontend_runtime_utility_pr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
setInputs,
setSecrets,
} from 'tests/utils/helpers';
import mockPackageJson from 'tests/package.json';

const repoName = 'frontend_runtime_utility_pr';

Expand Down Expand Up @@ -41,13 +40,6 @@ test('validate inputs and secrets', async () => {

expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`);

// magic_url
const magic_url_inputs = getTestResult({ results, name: 'magic_url_inputs' });

expect(magic_url_inputs.output).toContain(
`migration=${mockPackageJson.config.migration}`
);

// pr_comment
const pr_comment_inputs = getTestResult({
results,
Expand All @@ -65,10 +57,10 @@ test('default flow', async () => {

const jobs_found = getTestResults({
results,
names: ['pr_comment', 'migration_number', 'validate', 'magic_url'],
names: ['pr_comment', 'migration_number', 'validate'],
});

expect(jobs_found.length).toEqual(4);
expect(jobs_found.length).toEqual(3);
});

test('when use_validate is false', async () => {
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
repo
*.log
.DS_Store
temp
temp
*.tsbuildinfo
27 changes: 27 additions & 0 deletions bin/patch-mock-github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fs = require('node:fs');
const path = require('node:path');

const ORIGINAL = '__importDefault(require("simple-git"))';
const PATCHED = '{ default: require("simple-git").simpleGit }';

const repositoryDir = path.dirname(
require.resolve('@kie/mock-github/build/src/github/repository/repository-mocker.js')
);
const files = [
path.join(repositoryDir, 'repository-mocker.js'),
path.join(repositoryDir, 'state', 'repository-state.js'),
];

files.forEach((file) => {
const source = fs.readFileSync(file, 'utf8');

if (source.includes(PATCHED)) return;

if (!source.includes(ORIGINAL)) {
throw new Error(
`Cannot patch ${file}: expected "${ORIGINAL}". @kie/mock-github changed; update bin/patch-mock-github.js.`
);
}

fs.writeFileSync(file, source.split(ORIGINAL).join(PATCHED));
});
Loading
Loading