Skip to content

Deployment and CI scripts #25

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Deployment and CI scripts #25

wants to merge 19 commits into from

Conversation

Xendergo
Copy link
Contributor

@Xendergo Xendergo commented May 29, 2025

Add a bunch of shell scripts and nix files to enable deployment and integration testing on Vulcan through Github's CI

@9p4
Copy link
Contributor

9p4 commented Jun 1, 2025

I'll take a look tn

kdkasad

This comment was marked as resolved.

@kdkasad

This comment was marked as resolved.

Xendergo and others added 15 commits June 1, 2025 19:57
Since we're using command-restricted SSH keys, we can only run one
command per key. Instead of having to manage 4 separate keys to run each
script, we can just do, e.g., "ssh vulcan build" to execute build.sh.
The authorized_keys file will have command=".../launch.sh".
- Changes into ~/webring first
- Passes arguments along to script being invoked
@ArhanChaudhary
Copy link
Contributor

LGTM!

Copy link

@Infinidoge Infinidoge left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good. The biggest thing I recommend is moving home manager into the flake itself, and using Nix's syntax for building from a remote checkout to avoid needing to manage a cloned directory yourself. It would cut down on a lot of the work done in the CI scripts.


# Set up the testing directory in tmpfs

CI_PATH=/dev/shm/webring-ci

Choose a reason for hiding this comment

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

Technically it wouldn't be taking up storage, and instead taking up RAM.

Choose a reason for hiding this comment

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

Strictly speaking, you can just do nix build github:purduehackers/webring/<HASH> instead of checking out anything. This will fetch the commit directly from GitHub and build it, instead of needing to manage the worktree yourself.

This would also negate the cleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🔥

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Come to think of it, would it be possible to do this using the git repo's actual origin instead of hardcoding ours? It would be nice to not have to change it if the repo moves or someone forks the project.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we use nix build github:..., we'd only need that one command, not a whole script, right? If that's the case, we can just put that command directly in the GH Actions workflow and get the repository URL from the runner's environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, probably

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if we do that, the repo origin would be hardcoded in the github action rather than the repo itself...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically it could use git remote get-url origin. Its just that the nix build command doesn't seem to like taking in a link. I could probably figure that out.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we get the origin URL from a Git repository on Vulcan, that involves statefulness. The repository needs to exist, have an up-to-date origin URL, etc.

I think it would be better (as long as we don't need a full script) to just inject the URL from the GitHub Actions workflow. That way deploying is essentially stateless (except for the SSH key setup), which reduces the number of places in which we have to maintain things.

If we do need a script, then go ahead and use the origin URL from the repo on Vulcan, since it'll have to exist already for the script to be there. This is just for if we don't need to have a script, and the nix build ... command is enough.

};

Service = {
ExecStart = "${pkgs.bubblewrap}/bin/bwrap --bind /home/ring/webring-data /webring --ro-bind /nix/store /nix/store --ro-bind /etc /etc --tmpfs /tmp --unshare-all --share-net --new-session --chdir /webring --uid 256 --gid 512 --die-with-parent ${webring}/bin/ph-webring";

Choose a reason for hiding this comment

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

Instead of using bwrap inline here, it may be worthwhile to instead use the systemd unit file policies to represent a similar set of permissions. This would reduce the complexity of the command invocation.

The options you need are mainly in the Sandboxing section of systemd.exec

I will grant, I don't know if user units have restrictions on it, but I don't think it does in this case (outside of not being able to grant write access to paths it can't write to, of course.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There seem to be a lot of options in there and they're all allow by default. It looks like it would be a lot less config to keep the bwrap command since it's deny by default.

Choose a reason for hiding this comment

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

See previous comment about using nix commands with a github:... reference. If home manager is moved to the flake, this could be reduced down to home-manager switch --flake github:purduehackers/webring/<HASH>

@Xendergo Xendergo deployed to Testing June 4, 2025 22:25 — with GitHub Actions Active
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.

Rust rewrite
5 participants