Skip to content

Commit

Permalink
Merge pull request #1 from gabriel-samfira/add-ngrok
Browse files Browse the repository at this point in the history
Add ngrok
  • Loading branch information
mihaelabalutoiu authored Aug 2, 2023
2 parents 6f69f94 + 9927a18 commit 4fa83b6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,46 @@ jobs:
run: make build

- name: Setup GARM
run: sudo --preserve-env ./test/integration/scripts/setup-garm.sh
run: ./test/integration/scripts/setup-garm.sh
env:
GH_OAUTH_TOKEN: ${{ secrets.GH_OAUTH_TOKEN }}
CREDENTIALS_NAME: test-garm-creds

- name: Generate secrets
run: |
function randomStringGenerator() {
tr -dc "a-zA-Z0-9@#$%^&*()_+?><~\`;'" </dev/urandom | head -c 64 ; echo '';
}
GARM_PASSWORD=$(randomStringGenerator)
REPO_WEBHOOK_SECRET=$(randomStringGenerator)
ORG_WEBHOOK_SECRET=$(randomStringGenerator)
echo "::add-mask::$GARM_PASSWORD"
echo "::add-mask::$REPO_WEBHOOK_SECRET"
echo "::add-mask::$ORG_WEBHOOK_SECRET"
echo "GARM_PASSWORD=$GARM_PASSWORD" >> $GITHUB_ENV
echo "REPO_WEBHOOK_SECRET=$REPO_WEBHOOK_SECRET" >> $GITHUB_ENV
echo "ORG_WEBHOOK_SECRET=$ORG_WEBHOOK_SECRET" >> $GITHUB_ENV
- name: Set up ngrok
id: ngrok
uses: gabriel-samfira/[email protected]
with:
ngrok_authtoken: ${{ secrets.NGROK_AUTH_TOKEN }}
port: 9997
tunnel_type: http

- name: Run integration tests
run: go run ./test/integration/e2e.go
env:
GARM_BASE_URL: http://127.0.0.1:9997
GARM_BASE_URL: ${{ steps.ngrok.outputs.tunnel-url }}
GARM_USERNAME: admin
GARM_PASSWORD: ${{ secrets.GARM_ADMIN_PASSWORD }}
GARM_FULLNAME: Local GARM Admin
GARM_EMAIL: [email protected]
GARM_NAME: local_garm
CREDENTIALS_NAME: test-garm-creds
REPO_WEBHOOK_SECRET: ${{ secrets.REPO_WEBHOOK_SECRET }}
ORG_WEBHOOK_SECRET: ${{ secrets.ORG_WEBHOOK_SECRET }}

- name: Show GARM logs
if: always()
Expand Down
27 changes: 11 additions & 16 deletions test/integration/scripts/setup-garm.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#!/usr/bin/env bash
set -o errexit

if [[ $EUID -ne 0 ]]; then
echo "ERROR: Please run $0 script as root"
exit 1
fi

DIR="$(dirname $0)"
BINARIES_DIR="$DIR/../../../bin"
CONTRIB_DIR="$DIR/../../../contrib"
CONFIG_DIR="$DIR/../config"
BINARIES_DIR="$PWD/bin"
CONTRIB_DIR="$PWD/contrib"
CONFIG_DIR="$PWD/test/integration/config"

if [[ ! -f $BINARIES_DIR/garm ]] || [[ ! -f $BINARIES_DIR/garm-cli ]]; then
echo "ERROR: Please build GARM binaries first"
Expand Down Expand Up @@ -47,17 +42,17 @@ export JWT_AUTH_SECRET="$(generate_secret)"
export DB_PASSPHRASE="$(generate_secret)"

# Group "adm" is the LXD daemon group as set by the "canonical/setup-lxd" GitHub action.
useradd --shell /usr/bin/false --system --groups adm --no-create-home garm
sudo useradd --shell /usr/bin/false --system --groups adm --no-create-home garm

mkdir -p /etc/garm
cat $CONFIG_DIR/config.toml | envsubst > /etc/garm/config.toml
chown -R garm:garm /etc/garm
sudo mkdir -p /etc/garm
cat $CONFIG_DIR/config.toml | envsubst | sudo tee /etc/garm/config.toml
sudo chown -R garm:garm /etc/garm

mv $BINARIES_DIR/* /usr/local/bin/
cp $CONTRIB_DIR/garm.service /etc/systemd/system/garm.service
sudo mv $BINARIES_DIR/* /usr/local/bin/
sudo cp $CONTRIB_DIR/garm.service /etc/systemd/system/garm.service

systemctl daemon-reload
systemctl start garm
sudo systemctl daemon-reload
sudo systemctl start garm

wait_open_port 127.0.0.1 9997

Expand Down

0 comments on commit 4fa83b6

Please sign in to comment.