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

Change github action input map handling #3858

Open
de-jcup opened this issue Feb 7, 2025 · 0 comments
Open

Change github action input map handling #3858

de-jcup opened this issue Feb 7, 2025 · 0 comments
Labels

Comments

@de-jcup
Copy link
Member

de-jcup commented Feb 7, 2025

Situation

In our integration tests for the SecHub github action, we use currently a field mockedInputMap:

function initInputMap() {
mockedInputMap.clear();
mockedInputMap.set(input.PARAM_SECHUB_SERVER_URL, `https://localhost:${integrationTestContext.serverPort}`);
mockedInputMap.set(input.PARAM_SECHUB_USER, `${integrationTestContext.serverUserId}`);
mockedInputMap.set(input.PARAM_API_TOKEN, `${integrationTestContext.serverApiToken}`);
mockedInputMap.set(input.PARAM_CLIENT_VERSION, 'latest');
mockedInputMap.set(input.PARAM_ADD_SCM_HISTORY, 'false');
mockedInputMap.set(input.PARAM_REPORT_FORMATS, 'json');
mockedInputMap.set(input.PARAM_TRUST_ALL, 'true'); // self signed certificate in test...
mockedInputMap.set(input.PARAM_FAIL_JOB_ON_FINDING, 'true');
}

Each integrtion test calls this method!

When the integration tests would run parallel, the initialization could bring up flaky tests because the commonly used mockedInputMap could bring up race conditions...

Currently the integration test setup in package.json calls
jest --runInBand --testPathPattern='integrationtest.test.ts'

reading https://archive.jestjs.io/docs/en/24.x/cli#--runinband :

Run all tests serially in the current process

But if somebody runs the tests not with the --runInBand option, the test will become flaky!

Wanted

Even without --runInBand the tests shall be not flaky

Solution

  • change function initInputMap() to return a new created map
  • drop the field of the map
  • introduce an inputMapResolver , write tests...
  • change launcher to use a inputMapResolver
  • change mocking for integration test, use mock for inputMapResolver as parameter for launch...
  • adopt change also to https://github.com/mercedes-benz/sechub/blob/develop/github-actions/scan/src/main.ts
    use there a real inputMapResolver which resolves data from github core...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant