Skip to content

Commit

Permalink
Add E2E Test Workflow (#19)
Browse files Browse the repository at this point in the history
* Add E2E GitHub workflow

* Update env variables

* Add ssh key generation step

* Add commit hash support in workflow dispatch

* Hide log of token and root pass
  • Loading branch information
zliang-akamai authored Dec 13, 2023
1 parent b38eb87 commit 31d41db
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: E2E Tests

on:
workflow_dispatch:
inputs:
commit_sha:
description: 'The hash value of the commit.'
required: true
push:
branches:
- main
- dev

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
if: ${{ inputs.commit_sha != '' }}
with:
ref: ${{ inputs.commit_sha }}

- name: checkout repo
uses: actions/checkout@v4
if: ${{ inputs.commit_sha == '' }}

- name: update packages
run: sudo apt-get update -y

- name: setup python 3
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: install or update Python build system
run: python3 -m pip install -U wheel setuptools certifi pip

- name: install test dependencies
run: make test-deps

- name: generate local SSH key
run: ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N ""

- name: run e2e test
run: make e2e
env:
CLEANUP_TEST_LINODE_INSTANCE: true
LINODE_TOKEN: ${{ secrets.DX_LINODE_TOKEN }}
4 changes: 4 additions & 0 deletions hack/run-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
runner_id: '{{ lookup("file", playbook_dir ~ "/.e2e-runner-id") }}'

- name: Create a temporary token for the plugin to consume
no_log: true
linode.cloud.token:
label: "{{ temp_token_name }}-{{ run_id }}"
scopes: "events:read_write linodes:read_write"
Expand All @@ -42,6 +43,7 @@
register: temp_token

- name: Ensure the test instance is created
no_log: true
linode.cloud.instance:
label: "{{ label_prefix }}-{{ runner_id }}"
type: "{{ type }}"
Expand All @@ -57,6 +59,7 @@
wait_for: host="{{ create_inst.instance.ipv4[0] }}" port=22 delay=1 timeout=300

- name: Append host to the in-memory inventory
no_log: true
add_host:
hostname: "test-runner"
ansible_host: "{{ create_inst.instance.ipv4[0] }}"
Expand Down Expand Up @@ -128,6 +131,7 @@

tasks:
- name: Remove the temp token
no_log: true
linode.cloud.token:
label: "{{ temp_token_name }}-{{ run_id }}"
state: absent
Expand Down

0 comments on commit 31d41db

Please sign in to comment.