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

GitHub Server action, to run DA on GitHub #740

Merged
merged 12 commits into from
Oct 27, 2023
Merged

GitHub Server action, to run DA on GitHub #740

merged 12 commits into from
Oct 27, 2023

Conversation

BryceStevenWilley
Copy link
Collaborator

@BryceStevenWilley BryceStevenWilley commented Jul 31, 2023

Edit: Blocked by #760.

In this PR, I have:

  • Added tests for any new features or bug fixes (if relevant)
  • Added my changes to the CHANGELOG.md at the top, under the "Unreleased" section
  • Ensured issues that this PR closes will be automatically closed

Reason for this PR

Get things running without external issues.

Closes #756

TODO:

  • CHANGELOG
  • while loop when the server is starting (no 8 minute sleep)
  • research how to call ALKiln action from the same branch.

lib/utils/session_vars.js Outdated Show resolved Hide resolved
github_server/action.yml Outdated Show resolved Hide resolved
github_server/action.yml Outdated Show resolved Hide resolved
@plocket
Copy link
Collaborator

plocket commented Aug 14, 2023

Note: need to know what different errors look like in this process and document them (like missing env vars, missing config stuff, missing package dependencies, etc.)

[Conclusion: For missing config/packages/general docker container issues, we'll just need to tell people that they'll have to look at the docker log or use tmate in order to troubleshoot the problem. Made https://github.com//issues/817]

github_server/action.yml Outdated Show resolved Hide resolved
github_server/action.yml Outdated Show resolved Hide resolved
lib/docassemble/get_base_interview_url.js Outdated Show resolved Hide resolved
lib/docassemble/startserver.js Outdated Show resolved Hide resolved
tmp.bash Outdated Show resolved Hide resolved
lib/docassemble/startserver.js Outdated Show resolved Hide resolved
@plocket plocket removed the deep dive label Aug 15, 2023
@plocket
Copy link
Collaborator

plocket commented Aug 15, 2023

More notes in #753 (the PR made from that branch). I'll put the notes of my action experiments on https://github.com/SuffolkLITLab/ALKiln/tree/start_server_workflow in here so everything's in the same place.

The biggest issue I see as I work through this is that we run the github_server setup to get the interview on the server, but then we also run the regular setup and takedown, which will install the repo on the Playground. Do we want to double up that way? Is there a point to doing both? Where do we want to control whether those happen or not?

Testing bugs so far: In an 08/14 test run:

  • A wait of 700 still didn't give the server enough time to start (the curl happens after the sleep, so it should be showing that the server has already started, which it isn't). Bryce mentioned that we may not be able to look at what's going wrong very easily, so we'll have to figure out the next steps.
  • As suspected, SERVER_URL and friends were not defined in the ALKiln action itself: https://github.com/SuffolkLITLab/ALKiln/actions/runs/5863230862/job/15896328024#step:3:198. (at alkiln-startserver, where session_vars is first used).
  • REPO_URL also wasn't defined, which makes sense, but means we need to duplicate some of the work we're doing in the regular action.yml. It is needed in da_i.install_on_server. I'm not loving the amount of duplication we're having to do.

Thoughts:

Maybe we need to somehow break out into further actions to avoid duplication - an action for accepting input and creating env vars that happens before the other actions. It, or something else, would then need to manage calling the right follow-up actions. If we do that, the github server action can avoid the regular action.yml setup and takedown by just calling test ourselves.

This seems complicated and would require conditional logic with another env var or input, which we were trying to avoid by splitting these actions into separate scripts (as we discussed). We should discuss which is worse - the duplication or the additional input/env var. (I'm reluctant to use another input as we're running into duplication problems with our current ones.)

@BryceStevenWilley
Copy link
Collaborator Author

Seeing the state of things and the fact that we do still need to export / duplicate the env vars in both actions.ymls for things to be fully separate , I think the extra input to ALKiln/action.yml isn't that bad of an option; it can be optional, so it won't change any one's existing usage, and can default to the normal usage.

we're running into duplication problems with our current ones

If you're talking about v5 vs v4 duplication issues, this is v5 only.

@plocket plocket removed the deep dive label Aug 21, 2023
@plocket plocket added the blocked There's a reason this work can't move forward right now label Sep 20, 2023
@plocket plocket removed the blocked There's a reason this work can't move forward right now label Oct 7, 2023
@plocket plocket marked this pull request as ready for review October 25, 2023 19:51
BryceStevenWilley and others added 8 commits October 25, 2023 18:13
Starting to look into starting Docassemble servers in Github actions, we needed to:
* log-in to the server
* create an API key, and save it
* use said API key to install the package, so we have all of the dependencies
  This currently can install things, but can't properly keep track of the task_id
  for some reason? Need to look into it

Also started the full bash script (which would become the Github actions script)
for the process.
plocket and others added 3 commits October 25, 2023 18:13
if the var really does need to be saved in the config for storage
in between runs or in between setup, test, and takedown.
Implement GitHub server workflow and action

* Start new workflow file github_server.yml

Create github_server.yml

🤞

Use branch with the new action in the new workflow

Attempt to install package and test only two tests

Double the waiting time

Switch the action branch to the current branch

Publish and use alkiln-startserver bin

Install ALKiln with npm before using its darn script

* Use full jhpyle da image.

Co-authored-by: BryceStevenWilley <Bryce.Steven.Willey@gmail.com>

* Try to always print the final log, remove MAX default

* Use custom config, output values, wait for docker to start

Add tmate

Separate wait into next step

Remove conditional tmate

Remove sudo

Allow action to continue

Lengthen sleep time to give us time with detached tmate

Use input correctly (I hope...)

Avoid running ALKiln in the composite action and...

- Only start the server in the github_server composite action.
- Create outputs in that action. Print them in the workflow that
uses that composite action.
- Use a while loop to detect whether docker is done starting.
- Make a placeholder for a max docker start time input.

Remove `needs`. LLM's aren't perfect.

* Use INSTALL_METHOD input to control action.yml behavior

Decrease initial server wait time, try to run tests

Docker start time was much shorter than expected, so decreasing
the amount of hard-coded time to wait before starting to test
whether the server is loaded or not.

Also, used a different variable for stopping the while loop so
that race conditions don't prevent the success message from
getting logged.

Try to use var differently

Try different syntax for var

Try keeping env var. Can't use inputs just anywhere.

Use the correct alkiln version for the command

* Use relative paths for `uses:` to avoid editing val on every branch change

Use branch ref in `uses`, hard code tags for now, tweak var names,

clean up a bit

Try different var syntax

Try to use the full repo/branch ref as an env var

Try a full path instead

Go out two folders

Try path code given by llm phind

Try relative path again

Remove the action.yml filename, just reference the dir

Try to use var again

Use relative path again, again going out 2 dirs

Use tmate

Use tmate better

Just run tmate

Remove the reference to the file itself

* Use correct sign in step info for actual tests

* Use `dainstall` and health check, save docker artifact

Add tempt tmate to ALKiln test run to find interview on server

Try different base url ending in data/questions/

Bump version for new base interview url

Refine interview base url

Log full interview url

Our package name is different than our project name. Problem?

Bump version for package url test

Explore folders with tmate

Looking for something like /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ALKiln/data/questions

Match "ALKiln" folder name to package name as pip hasn't been able

to install the package and we're theorizing that that's the issue.

Change ALKilnTests to ALKiln, remove tmp dir, clean

Add tmate step to experiment with dainstall

Try to install using dainstall

Isolate repo name

Try new string substitution syntax

Fix typo

Remove debug log because its error is not worth solving

Run tests again since installation seems to be working

Actually activate tests

Troubleshoot syntax that was working before

Tweak indentation

Allow server install address without js installing on server

Bump feature version

Switch back to hard-coded API key

Set `result` in gh_server action

Add AL requirement

Add dangerous debug for debugging server action, clean up

Test the failing test

Log dangerous vars

Bump for log

Try a different password

Try to use output email and password as env vars

Log container name

Create logs artifact, attempt 1

Typo

Use absolute path for artifact

Change startserver -> server_install file/function name

Bump for file/function name change

Start exploring url/healt_check output

Try to disambiguate log of health check

Try to get just the status code

Tangent to try installing the package without cloning

Add shell. There must be something global.

Move reference to dir path for dainstall

Add in a test that actually uses the package

Use health_check response to check docker finished starting

Conform to github action output guidelines

Test docker install input

Restoring defaults as the input test was successful

Test all our tests

* Make missing file error test more broad

Make missing file error test more broad

Bump for missing file test and console log

* Remove `install_on_server` API request

* Use dainstall to install repo on server and...

use folder name to create interview address as the repo folder can have
different name from repo name. Leave interviews installed on remote
(non-github folders) and their installation process as it is.

This is a combination of 11 commits.

Change docassemble package folder back to ALKilnTests

Add tmate to experiment with #egg

Try to use inner folder name to get server location of interview

Log more info about the chosen folders. Also try to use fewer tests

Fail tag definition faster

Bump dev to test with right ALKiln version. Pass tags as input.

Add new ALKiln version

Fix typo in function name

Fix typo, use @server to install instead of @v#

Fix requested version number typo

Parse folder names differently

* Switch install_type -> install_method, abstract config save/get

* Run all ALKiln tests

* Apply PR suggestions

- Simplify getting docker logs now using our container name, though maybe this needs to use the var name
- `exit 1` on docker error
- Typo

Co-authored-by: Bryce Willey <Bryce.Steven.Willey@gmail.com>

* Remove the var `ready`, comments and cleanup

* Name the docker container (not getting output)

Also temp reduce to one test for testing output

* Handle no config value. Edit comments and clean.

* Re-activate all github server tests, tweak logs and comments

- Tweak logs and add comments
- Re-activate all github server tests
- More small clean up

* Tweak folder name, improve console logs, date/time foldername,

and clean up

* Remove dangerous debug

* Address docker log filename bash error with quotes and env var

Address docker log filename bash error with quotes and env var

Address docker log filename bash error with double quotes

Address filename error (date?) with env var `TZ` instead of -u arg

Restore one of the changes. Perhaps the bash is different in each

place? Though they both use bash.

Try double quotes

Use env var for filename to allow download to find the right file

Use env var for filename to allow download to find the right file

---------

Co-authored-by: BryceStevenWilley <Bryce.Steven.Willey@gmail.com>
@plocket
Copy link
Collaborator

plocket commented Oct 26, 2023

Docassemble core is giving the wrong error [and that's causing our tests to fail]. This is blocked till the next release when that should be fixed.

[Fixed!]

Copy link
Collaborator

@plocket plocket left a comment

Choose a reason for hiding this comment

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

I'm a bit too close to it, but from what I can tell we're good to put it out there.

@plocket plocket merged commit 7ddbe3c into v5 Oct 27, 2023
3 checks passed
@plocket plocket deleted the start_server_take_2 branch October 27, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants