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

ROX-21124: Move non-e2e testing OSCI jobs to GitHub Actions #1347

Merged
merged 17 commits into from
Jan 11, 2024

Conversation

BradLugo
Copy link
Contributor

@BradLugo BradLugo commented Dec 11, 2023

Description

These changes move the OpenShift CI jobs into GitHub Actions and change the updater to use an API token for grabbing NVD data.

Some interesting side-effects from this work:

  • We're able to download artifacts such as the genesis-dump directly from CI (i.e., without needing to pull the image)
  • We can run scanner code related CI (excluding e2e tests) without needing to wait for the data processing

Copy link

openshift-ci bot commented Dec 11, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@BradLugo BradLugo force-pushed the blugo/ROX-21124-initial branch 4 times, most recently from 874f959 to 112788f Compare December 15, 2023 20:08
@BradLugo BradLugo changed the title WIP ROX-21124: Move non-e2e testing OSCI jobs to GitHub Actions Dec 15, 2023
@BradLugo BradLugo force-pushed the blugo/ROX-21124-initial branch from 14d3b5c to 7aca1c8 Compare December 15, 2023 23:03
@BradLugo BradLugo force-pushed the blugo/ROX-21124-initial branch from 02ddd0c to 7e5f666 Compare December 19, 2023 19:34
@BradLugo BradLugo marked this pull request as ready for review December 19, 2023 19:36
@ghost
Copy link

ghost commented Dec 19, 2023

Images are ready for the commit at 1c61044.

To use the images, use the tag 2.31.x-92-g1c61044e44.

Copy link
Collaborator

@RTann RTann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THANK YOU for doing this. This is greatly appreciated

pkg/vulnloader/nvdloader/loader.go Outdated Show resolved Hide resolved
adduser pg -u 1001 -g 1001 -d /var/lib/postgresql -s /bin/sh

# The PATH is not completely preserved, so set the PATH here to ensure postgres-related commands can be found.
runuser -l pg -c "PATH=$PATH $SCRIPTS_ROOT/scripts/ci/postgres.sh _start_postgres" # TODO(DO NOT MERGE): this is a mess
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still a mess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love calling _start_postgres like this (I don't really even like the name tbh), but I don't fully understand idiomatic bash so 🤷. I also see some scripts use su <user> ... so I wasn't sure which should be used here. I'm fine to keep this as-is if y'all think it's fine

uses: ./.github/actions/cache-go-dependencies

- name: Build Scanner
run: make scanner-build-nodeps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember this too well, but I remember this was created because of OpenShift CI oddities (no idea what). Do you think we still need to skip the deps step? I guess we've been skipping it for over a year by this point, so I guess it's ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I think scanner-build-nodeps is a bit of a misnomer. AFAICT, it still grabs the dependencies anyway. That being said, now that I look at the deps target, it might be worth adding that step first (since it has some other dependent targets). The main reason I used scanner-build-nodeps (without deps) was because that's how we do it in stackrox/stackrox

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep it as-is to stay aligned with stackrox/stackrox

.github/workflows/build.yaml Outdated Show resolved Hide resolved
.github/workflows/build.yaml Outdated Show resolved Hide resolved
.github/workflows/build.yaml Outdated Show resolved Hide resolved
- name: diff-dumps
run: ./scripts/ci/jobs/diff-dumps.sh

# TODO(DO NOT MERGE): These store functions don't seem quite right
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's wrong with them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically what Gavin brought up here: https://github.com/stackrox/scanner/pull/1347/files#r1433028812
I'm not sure if these store functions are actually needed in GHA

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should be removed. The artifacts are stored earlier (and available through the GH UI) via upload-artifact.

scripts/ci/jobs/diff-dumps.sh Show resolved Hide resolved
scripts/ci/lib.sh Show resolved Hide resolved
scripts/ci/lib.sh Show resolved Hide resolved
@RTann
Copy link
Collaborator

RTann commented Dec 20, 2023

Build / generate-db-dump (pull_request) Successful in 44m

I missed this

Copy link
Contributor

@gavin-stackrox gavin-stackrox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some questions about testing which I'll bring up elsewhere.

Comment on lines 68 to 69
env:
ARTIFACT_DIR: /artifacts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a workflow env. i.e. only declare once: https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow

Can you make it /tmp/artifacts. In other environments we run with a RO root and limited user and using /tmp is a good practice.

Comment on lines 85 to 86
- name: Create artifacts dir
run: mkdir -p "$ARTIFACT_DIR"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a deeper look at this ARTIFACT_DIR. I think you can remove it from this PR. It is only used in store_test_results and that returns for non openshift environments without doing anything.

The only reason to save those Junit test results would be to display them with something like https://github.com/test-summary/action which could be done in a follow on PR if warranted (I don't think there is enough ongoing dev in stackrox/scanner to warrant it IMHO).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the implementation of store_test_results in this branch, but yeah, that's actually why I had comment at https://github.com/stackrox/scanner/pull/1347/files#diff-d0777657fa3fd81d23aaf7273e58aee453b04e67882517900c56daeef9b3e4c1R370. Would it make sense to remove all the usage of ARTIFACT_DIR and all the jobs that only call store_test_results?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. I missed that. I'd say remove store_test_results() from any test/job that is moved to GHA. The jobs that remain in OSCI will still benefit from it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this empty file, it is triggering an action failure.

@BradLugo BradLugo force-pushed the blugo/ROX-21124-initial branch from 41231dc to c0eecec Compare December 21, 2023 18:43
@BradLugo
Copy link
Contributor Author

fysa, upload-db-dump, upload-dumps-for-downstream, and upload-dumps-for-embedding are untested. Do y'all have any suggestions on how to test them?

.github/workflows/CI.yaml Outdated Show resolved Hide resolved
scripts/ci/lib.sh Show resolved Hide resolved
Comment on lines +259 to +260
github.event_name != 'pull_request' ||
contains(github.event.pull_request.labels.*.name, 'generate-dumps-on-pr')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be needs.generate-genesis-dump.result == 'success' maybe? Probably doesn't matter that much

@BradLugo
Copy link
Contributor Author

BradLugo commented Jan 9, 2024

Needs to be rebased once #1364 is merged.

@RTann
Copy link
Collaborator

RTann commented Jan 10, 2024

@BradLugo is the genesis dump accessible to a user who would want to download it? When cutting a new release, we will need access to the latest one generated from the master branch. Just remembered this

can be done in a followup PR, if not already done here

@BradLugo
Copy link
Contributor Author

@BradLugo is the genesis dump accessible to a user who would want to download it? When cutting a new release, we will need access to the latest one generated from the master branch. Just remembered this

@RTann Would this suffice? https://github.com/stackrox/scanner/actions/runs/7292017884

@RTann
Copy link
Collaborator

RTann commented Jan 10, 2024

@BradLugo is the genesis dump accessible to a user who would want to download it? When cutting a new release, we will need access to the latest one generated from the master branch. Just remembered this

@RTann Would this suffice? https://github.com/stackrox/scanner/actions/runs/7292017884

yep!

@BradLugo
Copy link
Contributor Author

/retest

@BradLugo
Copy link
Contributor Author

/override ci/prow/images ci/prow/style-checks ci/prow/unit-tests

Copy link

openshift-ci bot commented Jan 11, 2024

@BradLugo: Overrode contexts on behalf of BradLugo: ci/prow/images, ci/prow/style-checks, ci/prow/unit-tests

In response to this:

/override ci/prow/images ci/prow/style-checks ci/prow/unit-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@BradLugo
Copy link
Contributor Author

BradLugo commented Jan 11, 2024

All stackrox/stackrox tests passed: stackrox/stackrox#9146

@BradLugo BradLugo force-pushed the blugo/ROX-21124-initial branch from 1ec96a6 to 2dbcd09 Compare January 11, 2024 19:35
@BradLugo
Copy link
Contributor Author

/retest

Copy link

openshift-ci bot commented Jan 11, 2024

@BradLugo: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-tests 2dbcd09 link false /test e2e-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@BradLugo
Copy link
Contributor Author

e2e tests are fixed here: #1368

@BradLugo BradLugo merged commit bda5a7e into master Jan 11, 2024
15 of 17 checks passed
@BradLugo BradLugo deleted the blugo/ROX-21124-initial branch January 11, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants