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 workflows for building environments #195

Merged
merged 323 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
323 commits
Select commit Hold shift + click to select a range
190d07e
Run the correct installer file
cbaxley Feb 20, 2024
529fc0d
Run the installer from the root directory
cbaxley Feb 20, 2024
8fa24e6
Try a self hosted github runner
cbaxley Feb 20, 2024
5ca5555
Reduce logging for docker pull.
cbaxley Feb 20, 2024
2c87851
Adds quiet flag to docker pull command
cbaxley Feb 20, 2024
528b8b1
Pull the images before expect to reduce run time
cbaxley Feb 20, 2024
cfd590e
Install docker early in order to speed up install
cbaxley Feb 20, 2024
6322ffb
Builds the right docker-compose file
cbaxley Feb 20, 2024
b2de6e6
Increase timeout for linux install expect script
cbaxley Feb 20, 2024
9e62e01
Change timeout on expect script
cbaxley Feb 20, 2024
816d76a
Change the way expect watches the script
cbaxley Feb 20, 2024
a7196e0
Expand the timeout when waiting for Elasticsearch
cbaxley Feb 20, 2024
311fa06
Search for more output in the expect script
cbaxley Feb 20, 2024
7a2f0b1
Change the match for the dots in expect
cbaxley Feb 20, 2024
04c2c7c
Change the regex for matching dots
cbaxley Feb 20, 2024
d30d222
Change the output for catching dots
cbaxley Feb 20, 2024
743a269
Add chrome to Dockerfile for selenium
cbaxley Feb 21, 2024
88ef3d1
Merge branch 'main' into cbaxley-194-workflows
cbaxley Feb 21, 2024
156ff37
Import selenium tests and run python tests
cbaxley Feb 21, 2024
61d1b81
Activate venv when running tests
cbaxley Feb 21, 2024
bbf4f3c
Correct path for venv in the container
cbaxley Feb 21, 2024
e0ef274
Correct path for venv in the container
cbaxley Feb 21, 2024
b9d4488
Running only linux tests
cbaxley Feb 21, 2024
1ad6210
Adjust scripts to run as a non super user
cbaxley Feb 21, 2024
a8962eb
Change the permissions on the output log to source for environment va…
cbaxley Feb 21, 2024
c1acc00
Check for output log
cbaxley Feb 21, 2024
d4ce66a
Make output log available to test instantiation
cbaxley Feb 21, 2024
acef37b
Change pytest cache dir to home for user
cbaxley Feb 21, 2024
dfcc9bb
Change pytest cache dir to home for user
cbaxley Feb 21, 2024
01a7577
Change pytest cache dir permissions
cbaxley Feb 21, 2024
674bd62
Hide get-docker.sh from installs
cbaxley Feb 27, 2024
fb5db59
Cleanup test files in workflow
cbaxley Feb 27, 2024
7cfdef0
Add the cluster workflow for github actions
cbaxley Feb 27, 2024
8aba2f9
Adds a cluster build
cbaxley Feb 27, 2024
59ae44f
Merge branch 'cbaxley-168-python_tests' into cbaxley-194-workflows
cbaxley Feb 27, 2024
0a6015b
Run the test cluster in pwsh
cbaxley Feb 27, 2024
9cd15d6
Fail pipeline when commands fail
cbaxley Feb 28, 2024
858a51c
Catch the error from powershell
cbaxley Feb 28, 2024
1a29e6d
Remove duplicate run command
cbaxley Feb 28, 2024
e6df9fb
Set env vars explicitly
cbaxley Feb 28, 2024
1af3d4d
Modify the escape char for env vars
cbaxley Feb 28, 2024
d32b7d5
Try a different method of catching errors in pwsh script
cbaxley Feb 28, 2024
87a4c5c
Check failure of pwsh script
cbaxley Feb 28, 2024
7359ccb
Test successful run of build_cluster
cbaxley Feb 28, 2024
8dfd160
Test failure of script
cbaxley Feb 28, 2024
b48397d
Capture the output from the az commands
cbaxley Feb 28, 2024
9fd29e3
Continue on error condition
cbaxley Feb 28, 2024
c0b5691
Simplify run command
cbaxley Feb 28, 2024
8a49dd9
Try catching failures in a new way.
cbaxley Feb 28, 2024
28cd1d7
Test failure capture
cbaxley Feb 28, 2024
4d596d6
Setting error action to continue
cbaxley Feb 28, 2024
d1443eb
Remove ErrorAction
cbaxley Feb 28, 2024
e22e598
Use docker-compose run instead
cbaxley Feb 28, 2024
4c8ebc8
Capture exit code to fail step
cbaxley Feb 28, 2024
7612e3c
Try propigating errors from pwsh
cbaxley Feb 28, 2024
18eb182
Capture external command exit code
cbaxley Feb 28, 2024
0ee6975
Send lastexitcode
cbaxley Feb 28, 2024
490fa50
Don't exit right away
cbaxley Feb 28, 2024
3d92fa4
Disable immediate stop on exit
cbaxley Feb 28, 2024
2bea557
Run simple test for exit code
cbaxley Feb 28, 2024
0e8caa1
Cd to docker compose file
cbaxley Feb 28, 2024
d025add
Catch exec exit code
cbaxley Feb 28, 2024
5ecc6d6
Remove unneded flags from the command
cbaxley Feb 28, 2024
4f10dbc
Adds back in the build script
cbaxley Feb 28, 2024
f212d49
Adds an explicit exit for powershell script
cbaxley Feb 28, 2024
b690b6e
Remove spaces after escape character
cbaxley Feb 28, 2024
d2d8f31
Escape the exitcode variable in the shell command
cbaxley Feb 28, 2024
c2eb137
Remove extra exit from build_cluster.ps1
cbaxley Feb 28, 2024
3e36eec
Add a passing command for build_cluster.ps1
cbaxley Feb 28, 2024
922dfba
Move to the install directory
cbaxley Feb 28, 2024
67ed124
Run setup testbed to get an error
cbaxley Feb 28, 2024
13a23a6
Try to build a cluster with the build_cluster.ps1 script.
cbaxley Feb 28, 2024
60e5d81
Check resource group variable
cbaxley Feb 28, 2024
c002fca
Set the resource group name differently
cbaxley Feb 28, 2024
5030946
Build a cluster using the generated resource group
cbaxley Feb 28, 2024
5d76be2
Make the paths relative in the build_cluster script
cbaxley Feb 28, 2024
cd61f60
Move to the right directory to do an install
cbaxley Feb 28, 2024
34c04c3
Destroy cluster on pipeline finish
cbaxley Feb 29, 2024
8b48362
Change the owner of the files to match the host in the development co…
cbaxley Mar 1, 2024
ebbde81
Su user to remove testing files
cbaxley Mar 1, 2024
2dc23b2
Run the docker-compose as root to clean up
cbaxley Mar 1, 2024
8972dd7
Run as root to clean up containers
cbaxley Mar 1, 2024
bbf1f85
Build the cluster in azure
cbaxley Mar 1, 2024
fa419f7
List the files in the current directory on exec
cbaxley Mar 1, 2024
94d6ac3
Run the files from the new path
cbaxley Mar 1, 2024
b60e5dc
Investigate more about the file environment
cbaxley Mar 1, 2024
dec8cd7
Update the envornment for building the cluster
cbaxley Mar 1, 2024
f8c3e84
Update the environment users before docker up
cbaxley Mar 1, 2024
791de7d
Try to start hung job
cbaxley Mar 1, 2024
0788825
List all the files with their owners in the container
cbaxley Mar 1, 2024
19cef1e
Escape the powershell commands
cbaxley Mar 1, 2024
429c264
Check the paths and files with bash
cbaxley Mar 1, 2024
bbab08c
Find the path we are on
cbaxley Mar 1, 2024
6c2608d
Check powershell environment
cbaxley Mar 4, 2024
fb4cd73
Cd to home directory in powershell
cbaxley Mar 4, 2024
e7eee5f
Cd to home directory in powershell
cbaxley Mar 4, 2024
0928464
Rebuild docker compose as the right user
cbaxley Mar 4, 2024
9d430af
Change directory to source directory for powershell
cbaxley Mar 4, 2024
8e8c0cb
Change to proper directory for powershell
cbaxley Mar 4, 2024
eb67b61
Build a full cluster in pipeline
cbaxley Mar 4, 2024
1996ff6
Run the linux tests and check permissions of files
cbaxley Mar 4, 2024
e75f1ed
Change permissions on output file with sudo
cbaxley Mar 4, 2024
4d8fd36
Turn off cluster creation for speed
cbaxley Mar 4, 2024
09de7a7
Comment out building cluster in steps
cbaxley Mar 4, 2024
244a4f4
Only delete the resource group if it exists
cbaxley Mar 4, 2024
9307260
Merge branch 'main' into cbaxley-168-python_tests
cbaxley Mar 4, 2024
a12160a
Adds ability to get the public ip for fw rules
cbaxley Mar 5, 2024
124de87
Put the tags in quotes when creating nsg rules
cbaxley Mar 5, 2024
8f46d96
Output the command being run for nsg rules
cbaxley Mar 5, 2024
2e0812d
Remove tags for nsg port definitions
cbaxley Mar 5, 2024
9cbb7b4
Install lme on the cluster
cbaxley Mar 5, 2024
13841c5
Builds the full cluster install
cbaxley Mar 5, 2024
32e5d51
Cleans up the useage of the environment variables in pipeline
cbaxley Mar 6, 2024
11ebee1
Extract environment variables from the build script and use them in t…
cbaxley Mar 6, 2024
2babb63
Do a minimal linux install
cbaxley Mar 6, 2024
0d75ad4
Fix the path for retrieving env vars
cbaxley Mar 6, 2024
7e14d66
Check setting of github env
cbaxley Mar 6, 2024
41d5d7e
Source the env file and push it to github env
cbaxley Mar 6, 2024
98c610d
Print some debug information to the console
cbaxley Mar 6, 2024
5713ff0
Check setting of each key in functions
cbaxley Mar 6, 2024
e053a25
Parse the output for the passwords better
cbaxley Mar 6, 2024
ce44836
Uses a unique id instead of run_id to make sure it is unique
cbaxley Mar 6, 2024
dd6b565
Double quote the file name for sed in output.log
cbaxley Mar 7, 2024
64cbc04
Changes the way we get passwords from output.log
cbaxley Mar 7, 2024
852e2be
Make sure key doesn't have newline
cbaxley Mar 7, 2024
1f96345
Escape dollar sign
cbaxley Mar 7, 2024
caf88e7
Properly escape double quotes inside of docker-compose command
cbaxley Mar 7, 2024
026d33f
Escape all of the dollar signs in the compose command
cbaxley Mar 7, 2024
3c6f67b
Write the environment variables to the githut environment
cbaxley Mar 7, 2024
59c1346
Clean up debugging output
cbaxley Mar 7, 2024
6b8cc37
Remove more debugging output
cbaxley Mar 7, 2024
626ebc3
Remove set e
cbaxley Mar 7, 2024
3345d8d
Adds function to write passwords to a file for actions
cbaxley Mar 8, 2024
ac642ca
List files in directory after writing passwords
cbaxley Mar 8, 2024
cf676ef
Export the env vars in the github file
cbaxley Mar 8, 2024
5d94d94
Fail the workflow if the environment is not set correctly
cbaxley Mar 11, 2024
4098fd5
Clean up the environment vars for the container
cbaxley Mar 11, 2024
1eff838
Set the variables on run of the pwsh command
cbaxley Mar 11, 2024
7e6c198
Run commands on the domain controller
cbaxley Mar 11, 2024
e592e16
Get the envrionment checker to pass
cbaxley Mar 11, 2024
99a41cb
Update passing variables to remote script
cbaxley Mar 11, 2024
b230670
Escape the powershell environment variables
cbaxley Mar 11, 2024
65feba5
Change the case of the resource group env var
cbaxley Mar 11, 2024
74aca82
Don't destroy cluster so we can manually test
cbaxley Mar 11, 2024
852554a
Build the entire cluster to run commands against
cbaxley Mar 11, 2024
ba1c2c3
Run a command on the linux machine
cbaxley Mar 11, 2024
a6b6a36
Run remote tests
cbaxley Mar 12, 2024
81d5363
Run minimal installs to debug tests
cbaxley Mar 12, 2024
4b21d24
Fix escaping for test commands
cbaxley Mar 12, 2024
11d97e8
Move to the correct directory for tests
cbaxley Mar 12, 2024
e65bfb6
Add continuation characters to the lines in the script
cbaxley Mar 12, 2024
4222f2b
Remove nested double quotes
cbaxley Mar 12, 2024
3c9fc96
Uses the ip of LS1 to run the tests on
cbaxley Mar 12, 2024
ec1524a
Put the cluster build command on one line
cbaxley Mar 12, 2024
6f12635
Destroy clusters at the end
cbaxley Mar 12, 2024
56d4b3c
Quote output log correctly on build
cbaxley Mar 12, 2024
d8e1369
Run all api tests on cluster
cbaxley Mar 12, 2024
089eab9
Build full cluster and add verbose logging to pytest
cbaxley Mar 12, 2024
5f0f9c5
Stop deleting the cluster in the destroy_cluster.ps1 script
cbaxley Mar 12, 2024
588a5a9
Modify installer to use the new winlogbeat index pattern
cbaxley Mar 13, 2024
0797ce0
Try to get the dns to resolve ls1
cbaxley Mar 13, 2024
8011704
Add ls1 to the hosts file so it resolves always
cbaxley Mar 14, 2024
422f5e4
Modify tests to pass on a working cluster
cbaxley Mar 14, 2024
f602b76
Skip the fragile test for mapping
cbaxley Mar 14, 2024
d3c2ccf
Set up to run selenium tests on the cluster
cbaxley Mar 15, 2024
5be4c1f
Testing
cbaxley Mar 15, 2024
fe15ef9
Rerun build after rebasing to the right branch
cbaxley Mar 15, 2024
7425a9e
Pass the minimal install flag to install lme
cbaxley Mar 15, 2024
784279a
Build complete cluster and run all tests
cbaxley Mar 15, 2024
46da816
Pull the images quietly if running without a terminal.
cbaxley Mar 18, 2024
8d2c4ee
Run the simple tests on PR checkin and the longer ones when triggered
cbaxley Mar 18, 2024
b1241f7
Build the linux docker container upon check in of a pr
cbaxley Mar 18, 2024
599b044
Build lme container fresh before install
cbaxley Mar 20, 2024
4430565
Runs an end to end build in docker and cluster
cbaxley Mar 20, 2024
929c1a3
Print out the download feedback when pulling images
cbaxley Mar 20, 2024
e3b8395
Build 1.4.0 branch
cbaxley Mar 20, 2024
87a7cdc
Build the cluster using the main branch of the repository
cbaxley Mar 21, 2024
04a75c0
Allow passing branch to installers from the pipeline
cbaxley Mar 22, 2024
3e1473f
Run tests from a different base branch
cbaxley Mar 22, 2024
1a53d63
Remove the ampersand typo
cbaxley Mar 22, 2024
11af20f
Allow passing arguments to the installer scripts
cbaxley Mar 22, 2024
12b34dc
Rearrange install arguments
cbaxley Mar 22, 2024
6308f29
Test passing arguments in install lme
cbaxley Mar 22, 2024
c14a739
Build lme without arguments
cbaxley Mar 22, 2024
f4cf8d8
Install lme with no arguments
cbaxley Mar 25, 2024
559bcd3
Run command as string in install_lme.ps1
cbaxley Mar 25, 2024
b68427b
Build by passing arguments
cbaxley Mar 25, 2024
96a8d2f
Run a complete build using arguments
cbaxley Mar 25, 2024
59edc47
Update the sources to allow for updating in the pipeline
cbaxley Mar 28, 2024
7dd344d
Build the cluster using the latest branch
cbaxley Mar 28, 2024
9ec6aab
Set up the latest branch var
cbaxley Mar 29, 2024
a7bb520
Runs an upgrade in the pipeline
cbaxley Mar 29, 2024
b15c194
Run the upgrade in the remote linux machine
cbaxley Apr 1, 2024
65d2b84
Run upgrade on minimal install
cbaxley Apr 1, 2024
da0c76e
Checks out the current branch to run an upgrade on linux
cbaxley Apr 1, 2024
7b77cf6
Capture the exit code of the upgrade script
cbaxley Apr 1, 2024
e11efe5
Check the directories we are working in
cbaxley Apr 1, 2024
b3673de
Clone the git repository to run the upgrade
cbaxley Apr 1, 2024
8699689
Checkout the proper branch from origin
cbaxley Apr 2, 2024
20f3a6c
Get the remote username and home dir for the remote server
cbaxley Apr 2, 2024
ecd5553
Set the home directory for the az user
cbaxley Apr 2, 2024
07f0063
Use origin when checking out in the upgrade script
cbaxley Apr 2, 2024
e136262
Revert the changes to deploy.sh
cbaxley Apr 2, 2024
be71487
Set a dumb terminal to avoid terminal errors
cbaxley Apr 2, 2024
aafea1f
Export the terminal variable correctly
cbaxley Apr 2, 2024
2f0d817
Capture the output of the upgrade script to fail pipeline if it fails
cbaxley Apr 2, 2024
225c7e5
Revert previous changes as they seemed to break upgrade
cbaxley Apr 2, 2024
801bc66
Use a different format for executing the pwsh script
cbaxley Apr 2, 2024
a3c2b81
Destroy the cluster when done
cbaxley Apr 2, 2024
ea8e8a7
Output the upgrade information to the terminal
cbaxley Apr 3, 2024
c4c258e
Try capturing the docker-compose output
cbaxley Apr 3, 2024
05dbcdd
Directly capture the output of the compose command
cbaxley Apr 3, 2024
fa327ba
Fixes unbalanced quote
cbaxley Apr 3, 2024
f3c2338
Build and run full cluster with an upgrade
cbaxley Apr 3, 2024
4eeea43
Builds the current brand for the cluster
cbaxley Apr 4, 2024
6372009
Add a unique id for the docker-compose so you can run multiple instan…
cbaxley Apr 4, 2024
6ecf1ca
Adds upgrade.yml to gh workflows
cbaxley Apr 5, 2024
3fbcf4f
Runs both a build and an upgrade
cbaxley Apr 5, 2024
d7e567c
Adds upgrade to the gh workflows
cbaxley Apr 5, 2024
11306dc
Get gh to notice new workflow
cbaxley Apr 5, 2024
f275c8e
Match build names to parent branch
cbaxley Apr 5, 2024
c30b08c
Trigger gh to see the workflow
cbaxley Apr 5, 2024
33086ec
Get gh actions to trigger workflow
cbaxley Apr 5, 2024
3075ff9
Update code to get gh to see the actions
cbaxley Apr 6, 2024
d36cbf3
Update code to use the new workflow module.
cbaxley Apr 6, 2024
967c6f8
Trigger gh actions to run
cbaxley Apr 6, 2024
cbc0ace
Merge branch 'cbaxley-168-python_tests' into cbaxley-194-workflows
cbaxley Apr 6, 2024
37bbc51
Merge branch 'main' into cbaxley-168-python_tests
cbaxley Apr 6, 2024
7623749
Get gh to run workflows
cbaxley Apr 6, 2024
89a703e
Try to get gh to run workflows
cbaxley Apr 6, 2024
0445ab4
Merge branch 'cbaxley-168-python_tests' into cbaxley-194-workflows
cbaxley Apr 6, 2024
3e8886e
Change upgrade branch pulling
cbaxley Apr 8, 2024
cd7cbc9
Checking out branch for upgrade in a new way
cbaxley Apr 8, 2024
d529690
Rename workflow for upgrade
cbaxley Apr 8, 2024
589d2c7
Convert to docker compose
cbaxley Apr 8, 2024
359ccaa
Run all three builds using docker compose and -p
cbaxley Apr 8, 2024
eaf1d34
Clean up docker containers
cbaxley Apr 9, 2024
713fb6d
Build the docker containers fresh for the linux_only workflow
cbaxley Apr 9, 2024
030205d
Adds readme and checks an upgrade where the upgrade version is the sa…
cbaxley Apr 11, 2024
bba8cf8
Fixes typo in the workflow file
cbaxley Apr 11, 2024
1026576
Runs docker as sudo
cbaxley Apr 11, 2024
2d45e4e
Remove the privileged flag from the lme container
cbaxley Apr 12, 2024
cff222e
Try leaving the swarm on the host if running in non privileged enviro…
cbaxley Apr 12, 2024
e896e26
Leave the swarm on the host
cbaxley Apr 12, 2024
6358b09
Reset to run docker as privileged
cbaxley Apr 15, 2024
ecffe49
Installs the current branch in linux only
cbaxley Apr 15, 2024
5e2731b
Stop pruning system to see if elastc starts faster
cbaxley Apr 15, 2024
3b36dfb
Don't take down the docker containers to see why they aren't working
cbaxley Apr 15, 2024
b0a8268
Removes the gh actions shell escape vulnerability
cbaxley Apr 15, 2024
e7d6c2e
Remove the docker containers at end of run
cbaxley Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See the readme in `testing/development` for more information about these workflows and how to develop for them.
257 changes: 253 additions & 4 deletions .github/workflows/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,259 @@ name: Cluster Run

on:
workflow_dispatch:
# pull_request:
# branches:
# - '*'

jobs:
manual-job:
runs-on: ubuntu-latest
build-and-test-cluster:
runs-on: self-hosted
env:
UNIQUE_ID:
IP_ADDRESS:
LS1_IP:
BRANCH_NAME:
elastic:

steps:
- name: Greet
run: echo "This is a manually triggered workflow."
- name: Checkout repository
uses: actions/checkout@v4.1.1

- name: Setup environment variables
run: |
PUBLIC_IP=$(curl -s https://api.ipify.org)
echo "IP_ADDRESS=$PUBLIC_IP" >> $GITHUB_ENV
echo "UNIQUE_ID=$(openssl rand -hex 3 | head -c 6)" >> $GITHUB_ENV

- name: Get branch name
shell: bash
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
fi

- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

- name: Set the environment for docker-compose
run: |
cd testing/development
# Get the UID and GID of the current user
echo "HOST_UID=$(id -u)" > .env
echo "HOST_GID=$(id -g)" >> .env

# - name: Run Docker Compose Build to fix a user id issue in a prebuilt container
# run: |
# cd testing/development
# docker compose -p ${{ env.UNIQUE_ID }} build --no-cache

- name: Run Docker Compose
run: docker compose -p ${{ env.UNIQUE_ID }} -f testing/development/docker-compose.yml up -d

- name: List docker containers to wait for them to start
run: |
docker ps

- name: List files in home directory
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme bash -c "pwd && ls -la"

- name: Check powershell environment
run: |
set +e
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme pwsh -Command "& {
cd /home/admin.ackbar/LME; \
ls -la; \
exit \$LASTEXITCODE;
}"
EXIT_CODE=$?
echo "Exit code: $EXIT_CODE"
set -e
if [ "$EXIT_CODE" -ne 0 ]; then
exit $EXIT_CODE
fi

- name: Build the cluster
run: |
set +e
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme pwsh -Command "& {
cd /home/admin.ackbar/LME/testing; \
\$env:AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'; \
\$env:AZURE_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_CLIENT_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_TENANT='${{ secrets.AZURE_TENANT }}'; \
\$env:UNIQUE_ID='${{ env.UNIQUE_ID }}'; \
\$env:RESOURCE_GROUP='LME-pipe-${{ env.UNIQUE_ID }}'; \
\$env:IP_ADDRESS='${{ env.IP_ADDRESS }}'; \
./development/build_cluster.ps1 -IPAddress \$env:IP_ADDRESS; \
exit \$LASTEXITCODE;
}"
EXIT_CODE=$?
echo "Exit code: $EXIT_CODE"
set -e
if [ "$EXIT_CODE" -ne 0 ]; then
exit $EXIT_CODE
fi
cd ..
. configure/lib/functions.sh
extract_ls1_ip 'LME-pipe-${{ env.UNIQUE_ID }}.cluster.output.log'
echo "LS1_IP=$LS1_IP" >> $GITHUB_ENV

- name: Install lme on cluster
run: |
set +e
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme pwsh -Command "& {
cd /home/admin.ackbar/LME/testing; \
\$env:AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'; \
\$env:AZURE_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_CLIENT_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_TENANT='${{ secrets.AZURE_TENANT }}'; \
\$env:UNIQUE_ID='${{ env.UNIQUE_ID }}'; \
\$env:RESOURCE_GROUP='LME-pipe-${{ env.UNIQUE_ID }}'; \
./development/install_lme.ps1 -b '${{ env.BRANCH_NAME }}'; \
exit \$LASTEXITCODE;
}"
EXIT_CODE=$?
echo "Exit code: $EXIT_CODE"
set -e
if [ "$EXIT_CODE" -ne 0 ]; then
exit $EXIT_CODE
fi

- name: Set the environment passwords for other steps
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme bash -c "
cd /home/admin.ackbar/LME/testing \
&& . configure/lib/functions.sh \
&& extract_credentials 'LME-pipe-${{ env.UNIQUE_ID }}.password.txt' \
&& write_credentials_to_file '${{ env.UNIQUE_ID }}.github_env.sh' \
"
. ../${{ env.UNIQUE_ID }}.github_env.sh
rm ../${{ env.UNIQUE_ID }}.github_env.sh
echo "elastic=$elastic" >> $GITHUB_ENV
echo "kibana=$kibana" >> $GITHUB_ENV
echo "logstash_system=$logstash_system" >> $GITHUB_ENV
echo "logstash_writer=$logstash_writer" >> $GITHUB_ENV
echo "dashboard_update=$dashboard_update" >> $GITHUB_ENV

- name: Check that the environment variables are set
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme bash -c "
if [ -z \"${{ env.elastic }}\" ]; then
echo 'Error: env.elastic variable is not set' >&2
exit 1
else
echo 'Elastic password is set'
fi
"

# - name: Run a command on the domain controller
# run: |
# set +e
# cd testing/development
# docker compose -p ${{ env.UNIQUE_ID }} exec -T lme pwsh -Command "& {
# cd /home/admin.ackbar/LME/testing; \
# \$env:AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'; \
# \$env:AZURE_SECRET='${{ secrets.AZURE_SECRET }}'; \
# \$env:AZURE_CLIENT_SECRET='${{ secrets.AZURE_SECRET }}'; \
# \$env:AZURE_TENANT='${{ secrets.AZURE_TENANT }}'; \
# \$env:UNIQUE_ID='${{ env.UNIQUE_ID }}'; \
# \$env:RESOURCE_GROUP='LME-pipe-${{ env.UNIQUE_ID }}'; \
# az login --service-principal -u \$env:AZURE_CLIENT_ID -p \$env:AZURE_SECRET --tenant \$env:AZURE_TENANT; \
# az vm run-command invoke \
# --command-id RunPowerShellScript \
# --name DC1 \
# --resource-group \$env:RESOURCE_GROUP \
# --scripts 'ls C:\'; \
# exit \$LASTEXITCODE;
# }"
# EXIT_CODE=$?
# echo "Exit code: $EXIT_CODE"
# set -e
# if [ "$EXIT_CODE" -ne 0 ]; then
# exit $EXIT_CODE
# fi

- name: Run a command on the linux machine
run: |
set +e
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme pwsh -Command "& {
cd /home/admin.ackbar/LME/testing; \
\$env:AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'; \
\$env:AZURE_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_CLIENT_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_TENANT='${{ secrets.AZURE_TENANT }}'; \
\$env:UNIQUE_ID='${{ env.UNIQUE_ID }}'; \
\$env:RESOURCE_GROUP='LME-pipe-${{ env.UNIQUE_ID }}'; \
az login --service-principal -u \$env:AZURE_CLIENT_ID -p \$env:AZURE_SECRET --tenant \$env:AZURE_TENANT; \
az vm run-command invoke \
--command-id RunShellScript \
--name LS1 \
--resource-group \$env:RESOURCE_GROUP \
--scripts 'ls -lan'; \
exit \$LASTEXITCODE;
}"
EXIT_CODE=$?
echo "Exit code: $EXIT_CODE"
set -e
if [ "$EXIT_CODE" -ne 0 ]; then
exit $EXIT_CODE
fi

# This only passes when you do a full install
- name: Run api tests in container
run: |
set +e
cd testing/development
docker-compose -p ${{ env.UNIQUE_ID }} exec -T -u admin.ackbar lme bash -c " cd testing/tests \
&& echo export elastic=${{ env.elastic }} > .env \
&& echo export ES_HOST=${{ env.LS1_IP }} >> .env \
&& cat .env \
&& python3 -m venv /home/admin.ackbar/venv_test \
&& . /home/admin.ackbar/venv_test/bin/activate \
&& pip install -r requirements.txt \
&& sudo chmod ugo+w /home/admin.ackbar/LME/ -R \
&& pytest -v api_tests/"

- name: Run selenium tests in container
run: |
set +e
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T -u admin.ackbar lme bash -c " cd testing/tests \
&& echo export ELASTIC_PASSWORD=${{ env.elastic }} > .env \
&& . .env \
&& python3 -m venv /home/admin.ackbar/venv_test \
&& . /home/admin.ackbar/venv_test/bin/activate \
&& pip install -r requirements.txt \
&& sudo chmod ugo+w /home/admin.ackbar/LME/ -R \
&& python selenium_tests.py --domain ${{ env.LS1_IP }} -v"

- name: Cleanup environment
if: always()
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme pwsh -Command "& {
cd /home/admin.ackbar/LME/testing; \
\$env:AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'; \
\$env:AZURE_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_CLIENT_SECRET='${{ secrets.AZURE_SECRET }}'; \
\$env:AZURE_TENANT='${{ secrets.AZURE_TENANT }}'; \
\$env:UNIQUE_ID='${{ env.UNIQUE_ID }}'; \
\$env:RESOURCE_GROUP='LME-pipe-${{ env.UNIQUE_ID }}'; \
./development/destroy_cluster.ps1; \
exit \$LASTEXITCODE;
}"
docker compose -p ${{ env.UNIQUE_ID }} down
docker system prune --force
102 changes: 96 additions & 6 deletions .github/workflows/linux_only.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,101 @@
name: Linux Only
name: Linux Only

on:
workflow_dispatch:
jobs:
manual-job:
runs-on: ubuntu-latest
pull_request:
branches:
- '*'

jobs:
build-and-test-linux-only:
# runs-on: ubuntu-latest
runs-on: self-hosted

env:
UNIQUE_ID:
BRANCH_NAME:

steps:
- name: Greet
run: echo "This is a manually triggered workflow."
- name: Checkout repository
uses: actions/checkout@v4.1.1

- name: Setup environment variables
run: |
echo "UNIQUE_ID=$(openssl rand -hex 3 | head -c 6)" >> $GITHUB_ENV

- name: Setup environment variables
run: |
echo "AZURE_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }}" >> $GITHUB_ENV
echo "AZURE_SECRET=${{ secrets.AZURE_SECRET }}" >> $GITHUB_ENV
echo "AZURE_CLIENT_SECRET=${{ secrets.AZURE_SECRET }}" >> $GITHUB_ENV
echo "AZURE_TENANT=${{ secrets.AZURE_TENANT }}" >> $GITHUB_ENV
echo "AZURE_SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION_ID }}" >> $GITHUB_ENV

- name: Set Branch Name
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
HEAD_REF: ${{ github.head_ref }}
GITHUB_REF: ${{ github.ref }}
run: |
if [ "$EVENT_NAME" == "pull_request" ]; then
echo "BRANCH_NAME=$HEAD_REF" >> $GITHUB_ENV
else
BRANCH_REF="${GITHUB_REF##*/}"
echo "BRANCH_NAME=$BRANCH_REF" >> $GITHUB_ENV
fi

- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

- name: Set the environment for docker-compose
run: |
cd testing/development
# Get the UID and GID of the current user
echo "HOST_UID=$(id -u)" > .env
echo "HOST_GID=$(id -g)" >> .env

- name: Run Docker Build
run: docker compose -p ${{ env.UNIQUE_ID }} -f testing/development/docker-compose.yml build lme --no-cache

- name: Run Docker Compose
run: docker compose -p ${{ env.UNIQUE_ID }} -f testing/development/docker-compose.yml up -d

- name: List docker containers to wait for them to start
run: |
docker ps

- name: Execute commands inside ubuntu container
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T ubuntu bash -c "echo 'Ubuntu container built'"

- name: Install LME in container
run: |
set -x
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T lme bash -c "./testing/development/build_docker_lme_install.sh -b ${{ env.BRANCH_NAME }} \
&& sudo chmod go+r /opt/lme/Chapter\ 3\ Files/output.log"

- name: Run api tests in container
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T -u admin.ackbar lme bash -c ". testing/configure/lib/functions.sh \
&& sudo cp /opt/lme/Chapter\ 3\ Files/output.log . \
&& extract_credentials output.log \
&& sudo rm output.log \
&& sudo docker ps \
&& . /home/admin.ackbar/venv_test/bin/activate \
&& sudo chmod ugo+w /home/admin.ackbar/LME/ \
&& pytest testing/tests/api_tests/linux_only/ "

- name: Cleanup Docker Compose
if: always()
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T -u root lme bash -c "rm -rf /home/admin.ackbar/LME/.pytest_cache"
docker compose -p ${{ env.UNIQUE_ID }} down
docker system prune --force
Loading