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

Add GitHub workflow for integration tests #145

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 72 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Integration Tests
on:
schedule:
- cron: "0 0 * * *"

jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version-file: go.mod

- name: Setup LXD
uses: canonical/[email protected]

- name: Build GARM
run: make build

- name: Setup GARM
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: ${{ steps.ngrok.outputs.tunnel-url }}
GARM_USERNAME: admin
GARM_FULLNAME: Local GARM Admin
GARM_EMAIL: [email protected]
GARM_NAME: local_garm
ORG_NAME: gsamfira
REPO_NAME: garm-testing
CREDENTIALS_NAME: test-garm-creds

- name: Show GARM logs
if: always()
run: |
sudo systemctl status garm
sudo journalctl -u garm --no-pager
59 changes: 59 additions & 0 deletions test/integration/config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[default]
callback_url = "http://${GARM_METADATA_IP}:9997/api/v1/callbacks/status"
metadata_url = "http://${GARM_METADATA_IP}:9997/api/v1/metadata"

[metrics]
enable = true
disable_auth = false

[jwt_auth]
secret = "${JWT_AUTH_SECRET}"
time_to_live = "8760h"

[apiserver]
bind = "0.0.0.0"
port = 9997
use_tls = false

[database]
backend = "sqlite3"
passphrase = "${DB_PASSPHRASE}"
[database.sqlite3]
db_file = "/etc/garm/garm.db"

[[provider]]
name = "lxd_local"
provider_type = "lxd"
description = "Local LXD installation"
[provider.lxd]
unix_socket_path = "/var/snap/lxd/common/lxd/unix.socket"
include_default_profile = false
instance_type = "container"
secure_boot = false
project_name = "default"
[provider.lxd.image_remotes]
[provider.lxd.image_remotes.ubuntu]
addr = "https://cloud-images.ubuntu.com/releases"
public = true
protocol = "simplestreams"
skip_verify = false
[provider.lxd.image_remotes.ubuntu_daily]
addr = "https://cloud-images.ubuntu.com/daily"
public = true
protocol = "simplestreams"
skip_verify = false
[provider.lxd.image_remotes.images]
addr = "https://images.linuxcontainers.org"
public = true
protocol = "simplestreams"
skip_verify = false

[[github]]
name = "${CREDENTIALS_NAME}"
description = "GARM GitHub OAuth token"
oauth2_token = "${GH_OAUTH_TOKEN}"

[[github]]
name = "${CREDENTIALS_NAME}-clone"
description = "GARM GitHub OAuth token - clone"
oauth2_token = "${GH_OAUTH_TOKEN}"
Loading