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

Run automated test of Sage Install Script #113

Merged
merged 114 commits into from
Sep 26, 2023

Conversation

jazzsequence
Copy link
Contributor

@jazzsequence jazzsequence commented Sep 21, 2023

This PR creates a new GH action workflow to test the Sage Theme install script (in ./private/scripts/helpers.sh) on MacOS and Linux environments (ubuntu-latest and macos-latest). (Windows tests were attempted but ultimately abandoned due to issues in Terminus and a lack of support for Windows Terminus installs.)

The matrix of tests has been configured to use PHP 8.x versions on each of the OSes it's being tested on (Roots Bedrock does not support < PHP 8).

In addition, changes to the script has been made so it can be run without user input via environment variables. These environment variables can be used to define any of the user input fields as well as whether the script is being run by a CI.

Future improvements could include Windows support (pending official support in the Terminus project), an environment variable for PHP version (so each PHP version in the matrix is actually updated so the created multidev is using that PHP version) (this has been rolled in) and documentation for using the environment variables (documentation has been added), and testing on WordPress multisite.

closes #112

need to add a no-input parameter for the install script
based on the os, pr, and php version
add the current directory to the PATH variable so we can run terminus from where we downloaded it
terminus isn't technically supported on windows so this is kind of moot
we might not actually need this if we're in the site directory...
can't believe I went this long without realizing we're going to need to run this in an actual site directory
@jazzsequence jazzsequence changed the title 112 try testing sage install script Run automated test of Sage Install Script Sep 25, 2023
since we're not opening the window, we don't need to switch to sftp and then switch back
just don't open the browser
@jazzsequence jazzsequence merged commit 2b6c488 into default Sep 26, 2023
@jazzsequence jazzsequence deleted the 112-try-testing-sage-install-script branch September 26, 2023 17:35
jazzsequence added a commit that referenced this pull request Jul 31, 2024
* adds a sage-test workflow

* temporarily allow the test to run on any branch so we can see if it works

* add to on push to test the test

* pull terminus.phar from latest

* authenticate with terminus

* this is a github secret, not an environment variable

* create a multidev for the build in a separate step
need to add a no-input parameter for the install script

* add a step to generate a name for our multidev
based on the os, pr, and php version

* use github.event.number

* run a cleanup step that deletes the multidev

* add an echo so we can save the output of the pr number

* get the pr number a different way?

* remove core const if already declared

* echo the PR number?

* echo all the things

* use gh cli?

* get the pr number the right way

* explicitly set the shell to bash everywhere

* set the default shell to bash and remove the definitions

* if we're in a windows environment, how we install terminus differs
add the current directory to the PATH variable so we can run terminus from where we downloaded it

* Sage (and Bedrock) doesn't actually work on PHP 7.4

* remove windows tests
terminus isn't technically supported on windows so this is kind of moot

* install terminus from homebrew if macos

* add a test that terminus works

* add latest version back

* shorten the test name

* support values to be globally set

* globally set values
we might not actually need this if we're in the site directory...

* clone down the site
can't believe I went this long without realizing we're going to need to run this in an actual site directory

* sync the latest changes to the test multidev

* wrap sitename in quotes

* install ssh key so we can clone

* clone site before multidev creation
if it's going to fail, let's fail before we wait for the multidev to be created

* deal with pantheon ssh host keys

* remove the ssh-keyscan step

* need to set a git config before we can git things

* make sure we're in the right directory

* add a check for CI
so we don't loop through the script

* export our globals
so they are read by the script

* don't prompt for confirmation if ci

* wait longer for CI since there are concurrent builds

* move these to be global variables and add a siteenv variable

* use siteenv anywhere we'd manually set .dev

* define the SITEENV to the multidev name

* lower the waittime to 300
i think 600 might be too much

* wait for long running scripts but wait shorter
but still vary it based on whether we're on ci or local

* add colors

* output that we're checking for jq

* allow sed handing between linux and macos and bail if it fails

* fix sed condition for shellcheck

* print current working directory

* sed conditional needs to go inside the ostype condition

* add closing fi

* add a check for the sage theme directory

* move the git pull to after we push the post install cmd
i think this isn't actually getting pushed

* remove random + that must've been a typo

* sitename.siteenv

* halve the waittime yet again

* push to the right branch

* only try opening the site if we're not in ci

* wrap $branch in quotes

* remove composer install step
we do this again later inside the multidev that we clone down, so there's no reason to do this before we create the multidev

* break terminus stuff up into multiple steps

* delete sage theme if it exists

* composer install after copying updates from source

* git diff before create multidev

* git status instead of git diff
bail if dirty

* temporarily gitignore sage test to create multidev

* delete all tags from the CI site

* delete the build artifact tag

* remove the gitignore steps
we don't need them
or we shouldn't, anyway

* fetch the tags before deleting the multidev artifact

* remove extra git pushes
so we have less sync code failures

* underscore in the build artifact tag name

* the other underscore, too

* allow other versions of PHP

* change output from listing to checking
we don't output the themes dir, so we shouldn't sey we're listing it

* add 8.3

* allow the build artifact tag deletion to fail
if it doesn't exist, that's okay

* actually bump the PHP version to the version declared

* add a note when checking for unfinished/long-running workflows

* allow both tag deletes to fail

* remove pwd

* set phpversion to 8.0 if 8 is passed

* do a git status to see the change

* bump version of ssh-agent

* set output will be deprecated so use env variables instead
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

* get and set in the same step

* remove the run of this workflow on every push
just need it on merges and when we make changes to the scripts or this workflow

* run the workflow whenever updates are pushed the test itself

* add documentation for running the script headless

* update path to script

* update docs about CI env variable

* remove extra line

* update changelog

* remove preceding slash for path to scripts

* fix spacing

* use latest terminus rather than figuring out a version

* Don't worry about checking the exit code

Co-authored-by: Phil Tyler <[email protected]>

* add a newline before php_version

Co-authored-by: Phil Tyler <[email protected]>

* default to 0

* fix missing info prompt

* git diff, not status

* fix typo

Co-authored-by: Phil Tyler <[email protected]>

* use $siteenv

* use env varibales

* move the path filter for the scripts folder to push
instead of PR, which doesn't seem to be triggering

* wrap multidev_name in quotes

* export SITEENV inside the script
$multidev_name is not carrying over

* use multidev_name from env

* all caps env variables

* don't switch to sftp mode
since we're not opening the window, we don't need to switch to sftp and then switch back

* actually we can still commit leftover files
just don't open the browser

---------

Co-authored-by: Phil Tyler <[email protected]>
jazzsequence added a commit that referenced this pull request Aug 1, 2024
* adds a sage-test workflow

* temporarily allow the test to run on any branch so we can see if it works

* add to on push to test the test

* pull terminus.phar from latest

* authenticate with terminus

* this is a github secret, not an environment variable

* create a multidev for the build in a separate step
need to add a no-input parameter for the install script

* add a step to generate a name for our multidev
based on the os, pr, and php version

* use github.event.number

* run a cleanup step that deletes the multidev

* add an echo so we can save the output of the pr number

* get the pr number a different way?

* remove core const if already declared

* echo the PR number?

* echo all the things

* use gh cli?

* get the pr number the right way

* explicitly set the shell to bash everywhere

* set the default shell to bash and remove the definitions

* if we're in a windows environment, how we install terminus differs
add the current directory to the PATH variable so we can run terminus from where we downloaded it

* Sage (and Bedrock) doesn't actually work on PHP 7.4

* remove windows tests
terminus isn't technically supported on windows so this is kind of moot

* install terminus from homebrew if macos

* add a test that terminus works

* add latest version back

* shorten the test name

* support values to be globally set

* globally set values
we might not actually need this if we're in the site directory...

* clone down the site
can't believe I went this long without realizing we're going to need to run this in an actual site directory

* sync the latest changes to the test multidev

* wrap sitename in quotes

* install ssh key so we can clone

* clone site before multidev creation
if it's going to fail, let's fail before we wait for the multidev to be created

* deal with pantheon ssh host keys

* remove the ssh-keyscan step

* need to set a git config before we can git things

* make sure we're in the right directory

* add a check for CI
so we don't loop through the script

* export our globals
so they are read by the script

* don't prompt for confirmation if ci

* wait longer for CI since there are concurrent builds

* move these to be global variables and add a siteenv variable

* use siteenv anywhere we'd manually set .dev

* define the SITEENV to the multidev name

* lower the waittime to 300
i think 600 might be too much

* wait for long running scripts but wait shorter
but still vary it based on whether we're on ci or local

* add colors

* output that we're checking for jq

* allow sed handing between linux and macos and bail if it fails

* fix sed condition for shellcheck

* print current working directory

* sed conditional needs to go inside the ostype condition

* add closing fi

* add a check for the sage theme directory

* move the git pull to after we push the post install cmd
i think this isn't actually getting pushed

* remove random + that must've been a typo

* sitename.siteenv

* halve the waittime yet again

* push to the right branch

* only try opening the site if we're not in ci

* wrap $branch in quotes

* remove composer install step
we do this again later inside the multidev that we clone down, so there's no reason to do this before we create the multidev

* break terminus stuff up into multiple steps

* delete sage theme if it exists

* composer install after copying updates from source

* git diff before create multidev

* git status instead of git diff
bail if dirty

* temporarily gitignore sage test to create multidev

* delete all tags from the CI site

* delete the build artifact tag

* remove the gitignore steps
we don't need them
or we shouldn't, anyway

* fetch the tags before deleting the multidev artifact

* remove extra git pushes
so we have less sync code failures

* underscore in the build artifact tag name

* the other underscore, too

* allow other versions of PHP

* change output from listing to checking
we don't output the themes dir, so we shouldn't sey we're listing it

* add 8.3

* allow the build artifact tag deletion to fail
if it doesn't exist, that's okay

* actually bump the PHP version to the version declared

* add a note when checking for unfinished/long-running workflows

* allow both tag deletes to fail

* remove pwd

* set phpversion to 8.0 if 8 is passed

* do a git status to see the change

* bump version of ssh-agent

* set output will be deprecated so use env variables instead
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

* get and set in the same step

* remove the run of this workflow on every push
just need it on merges and when we make changes to the scripts or this workflow

* run the workflow whenever updates are pushed the test itself

* add documentation for running the script headless

* update path to script

* update docs about CI env variable

* remove extra line

* update changelog

* remove preceding slash for path to scripts

* fix spacing

* use latest terminus rather than figuring out a version

* Don't worry about checking the exit code

Co-authored-by: Phil Tyler <[email protected]>

* add a newline before php_version

Co-authored-by: Phil Tyler <[email protected]>

* default to 0

* fix missing info prompt

* git diff, not status

* fix typo

Co-authored-by: Phil Tyler <[email protected]>

* use $siteenv

* use env varibales

* move the path filter for the scripts folder to push
instead of PR, which doesn't seem to be triggering

* wrap multidev_name in quotes

* export SITEENV inside the script
$multidev_name is not carrying over

* use multidev_name from env

* all caps env variables

* don't switch to sftp mode
since we're not opening the window, we don't need to switch to sftp and then switch back

* actually we can still commit leftover files
just don't open the browser

---------

Co-authored-by: Phil Tyler <[email protected]>
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.

Hey, we can actually test that our Sage Install Script runs
2 participants