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

Migrate CI to Github Actions #168

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Conversation

geedo0
Copy link

@geedo0 geedo0 commented Aug 21, 2024

We are hitting the 1 hour time limit of Circle CI (Issue #166). This migrates the existing CircleCI job completely to Github Actions which has a 5 hour time limit.

For the most part, this is pretty much a one-to-one migration. Since upstream OpenSSH provided its own set of Github Actions, I simply moved those to the upstream-github directory to avoid conflicts and preserve the source. I did run into two issues with getting the integration tests to pass. Beyond that, I ran into two issues that arose from migrating to Github Actions which need to be partched around.

agent-subprocess zombie process reaping

The combination of Github Actions' host with the OQS CI container results in a lazier reaping of zombie processes which breaks this test. In this test, ssh-agent is run as a subprocess to some arbitrary user command. This enables exclusive access to ssh-agent to that specific process. The way this works under the hood is that ssh-agent forks into a child process and the parent process exec's into the arbitrary command (code ref) which runs to completion. The child process than polls its parent process until it detects its own orphaned status and terminates itself. This, by design, results in a zombie process which must be reaped. The test's assertion uses kill -0 to check for liveness, but that counts zombies as "alive". The workaround for this then is to add an additional check to assert that zombies are in fact "dead".

percent expansion is broken due to Github's HOME override

The percent test tests % expansions inside SSH config files (e.g. home directory, username, port number). The assertion for the home directory uses the HOME environmental variable. Unfortunately, when running a container on a Github Runner, they unconditionally override the value of HOME with /github/home (issue ref) and this breaks the test assertion. The fix here is to get a more reliable reference for the home directory and use that for the assertion.

We are hitting the 1 hour time limit of Circle CI (Issue open-quantum-safe#166). This migrates the existing CircleCI job completely to Github Actions which has a 5 hour time limit.

For the most part, this is pretty much a one-to-one migration. Since upstream OpenSSH provided its own set of Github Actions, I simply moved those to the `upstream-github` directory to avoid conflicts and preserve the source. I did run into two issues with getting the integration tests to pass. Beyond that, I ran into two issues that arose from migrating to Github Actions which need to be partched around.

agent-subprocess zombie process reaping

The combination of Github Actions' host with the OQS CI container results in a lazier reaping of zombie processes which breaks this test. In this test, ssh-agent is run as a subprocess to some arbitrary user command. This enables exclusive access to ssh-agent to that specific process. The way this works under the hood is that ssh-agent forks into a child process and the parent process exec's into the arbitrary command ([code ref](https://github.com/open-quantum-safe/openssh/blob/OQS-v9/ssh-agent.c#L2384)) which runs to completion. The child process than polls its parent process until it detects its own orphaned status and terminates itself. This, by design, results in a zombie process which must be reaped. The test's assertion uses `kill -0` to check for liveness, but that counts zombies as "alive". The workaround for this then is to add an additional check to assert that zombies are in fact "dead".

percent expansion is broken due to Github's HOME override

The `percent` test tests % expansions inside SSH config files (e.g. home directory, username, port number). The assertion for the home directory uses the `HOME` environmental variable. Unfortunately, when running a container on a Github Runner, they unconditionally override the value of `HOME` with `/github/home` ([issue ref](actions/runner#863)) and this breaks the test assertion. The fix here is to get a more reliable reference for the home directory and use that for the assertion.

Signed-off-by: Gerardo Ravago <gcr@amazon.com>
Copy link
Member

@baentsch baentsch left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM. @dstebila you may want to click "Stop building" openssh in the CCI dashboard when this lands. It seems that also there I don't have the required permissions to do so myself.

@dstebila
Copy link
Member

Thanks! LGTM. @dstebila you may want to click "Stop building" openssh in the CCI dashboard when this lands. It seems that also there I don't have the required permissions to do so myself.

I don't have permissions for that either, it'll be up to @ryjones to do that.

@ryjones
Copy link

ryjones commented Aug 21, 2024

@dstebila just tell me when you want me to do it - are you sure you can't do it?

Copy link
Member

@SWilson4 SWilson4 left a comment

Choose a reason for hiding this comment

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

LGTM barring one nit. Since this is coming from a fork, I won't be able to trigger the workflow from liboqs until it's merged, so I'll get that working once this lands.

.github/workflows/ubuntu.yaml Outdated Show resolved Hide resolved
Co-authored-by: Spencer Wilson <spencer.wilson@uwaterloo.ca>
Signed-off-by: Gerardo Ravago <gerardo@gcr.me>
@geedo0 geedo0 marked this pull request as ready for review August 21, 2024 16:36
@geedo0 geedo0 merged commit 0360c98 into open-quantum-safe:OQS-v9 Aug 21, 2024
2 of 3 checks passed
@geedo0 geedo0 deleted the gh-actions branch August 21, 2024 16:37
@geedo0
Copy link
Author

geedo0 commented Aug 21, 2024

I saw the CI pass prior to addressing the nit so I went ahead and merged to unblock @SWilson4's liboqs PR. CircleCI job can be removed at anytime now.

@SWilson4
Copy link
Member

OK, I missed some fine print in the GitHub API documentation: workflows can only be triggered if their YAML file is on the default branch. This means that in order to get the upstream trigger working, we'll need to either change the default branch to OQS-v9 or also add the workflow file to the OQS-v8 branch.

The former approach seems cleaner to me: are we OK with updating the default branch to OQS-v9? It's the active dev branch anyway. @baentsch @christianpaquin @dstebila

@SWilson4
Copy link
Member

Alternatively, we could always tack the changes onto #153 and finally close that PR out.

@geedo0
Copy link
Author

geedo0 commented Aug 21, 2024

I'd advocate for OQS-v9 being the default branch. It's currently at parity with OQS-v8. My only hesitation is that a versioned release has not been cut for it yet.

@dstebila
Copy link
Member

I'd advocate for OQS-v9 being the default branch. It's currently at parity with OQS-v8. My only hesitation is that a versioned release has not been cut for it yet.

I agree, we can make OQS-v9 the default branch. No worries that there's not a release on it yet.

@SWilson4
Copy link
Member

Changing the default branch requires admin perms, so I've asked @ryjones to swap it out for us.

@ryjones
Copy link

ryjones commented Aug 21, 2024

Changing the default branch requires admin perms, so I've asked @ryjones to swap it out for us.

done

@dstebila
Copy link
Member

@dstebila just tell me when you want me to do it - are you sure you can't do it?

The button's disabled for me, see attached.

I think it is fine to do it now.

Screenshot 2024-08-21 at 11 22 14 AM

@ryjones
Copy link

ryjones commented Aug 21, 2024

@dstebila done!

@SWilson4
Copy link
Member

The (not-yet-merged) upstream trigger is triggering as expected: https://github.com/open-quantum-safe/openssh/actions/runs/10495477066.

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.

5 participants