Files
threshold-ui/.github/workflows/test-e2e-admin-ui.yaml
T

340 lines
13 KiB
YAML

name: Test E2E Admin UI
on:
pull_request:
types: [labeled, opened, synchronize, reopened]
workflow_dispatch:
inputs:
boundary-enterprise-branch:
description: 'Branch of boundary-enterprise to test against (default to main)'
required: true
default: 'main'
type: string
boundary-branch:
description: 'Branch of boundary to test against (default to main)'
required: true
default: 'main'
type: string
jobs:
setup:
name: setup matrix
# don't need to run e2e tests on ce -> ent merges since tests were already
# run in the ce branch, and there are currently no code differences between
# the two repos
if: github.actor != 'hc-github-team-secure-boundary'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
BOUNDARY_BRANCH="${{ github.event.inputs.boundary-branch || 'main' }}"
ENT_BRANCH="${{ github.event.inputs.boundary-enterprise-branch || 'main' }}"
if [[ "${{ github.repository }}" == "hashicorp/boundary-ui" ]]; then
matrix=$(jq -cn --arg branch "$BOUNDARY_BRANCH" '{
browser: ["chromium", "firefox", "webkit"],
include: [{
boundary_edition: "community",
github_repo: "hashicorp/boundary",
folder_name: "boundary",
boundary_edition_short: "oss",
enos_scenario: "e2e_ui_docker",
test_command: "admin:ce:docker",
boundary_branch: $branch
}]
}')
else
matrix=$(jq -cn --arg branch "$ENT_BRANCH" '{
browser: ["chromium", "firefox", "webkit"],
include: [{
boundary_edition: "enterprise",
github_repo: "hashicorp/boundary-enterprise",
folder_name: "boundary-enterprise",
boundary_edition_short: "ent",
enos_scenario: "e2e_ui_docker_ent",
test_command: "admin:ent:docker",
boundary_branch: $branch
}]
}')
fi
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
test:
name: test
needs: setup
runs-on: ${{ fromJSON(vars.RUNNER_UBUNTU_22) }}
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
fail-fast: false
env:
ENOS_VAR_e2e_debug_no_run: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
- name: Set up pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 #v6.0.8
with:
cache: true
cache_dependency_path: |
pnpm-lock.yaml
ui/desktop/electron-app/pnpm-lock.yaml
run_install: false
- name: Set up Terraform
uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e
- name: Set up Enos
uses: hashicorp/action-setup-enos@6ec106c8f809fe645162d73bea565c65f3269907
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Vault CLI
run: |
wget https://releases.hashicorp.com/vault/1.17.6/vault_1.17.6_linux_amd64.zip -O /tmp/vault.zip
if [[ "${{ github.repository }}" == "hashicorp/boundary-ui" ]]; then
unzip -o -q /tmp/vault.zip -d /usr/local/bin
elif [[ "${{ github.repository }}" == "hashicorp/boundary-ui-enterprise" ]]; then
unzip -o -q /tmp/vault.zip -d "$HOME/bin"
fi
- name: GPG setup
run: |
# Create a GPG key
export KEY_PW=boundary
gpg --generate-key --batch <<eoGpgConf
%echo Started!
Key-Type: RSA
Key-Length: default
Subkey-Type: RSA
Name-Real: boundary
Name-Comment: default
Name-Email: default
Expire-Date: 0
Passphrase: $KEY_PW
%commit
%echo Done.
eoGpgConf
# Enable gpg-preset-passphrase so that key passwords can be saved
echo "allow-preset-passphrase" >> ~/.gnupg/gpg-agent.conf
gpg-connect-agent reloadagent /bye &>/dev/null
# Get information about the created keys
export lines=$(gpg --list-secret-keys --with-colons --with-keygrip)
export KEY_ID=""
while read -r line
do
# Save the first key id to be used later
if [[ $line =~ "fpr"* ]]; then
if [[ $KEY_ID == "" ]]; then
KEY_ID="$(echo "$line" | sed -r 's/fpr|://g')"
fi
fi
# Cache the passphrases for the keys so passwords do not need to be entered
if [[ $line =~ "grp"* ]]; then
export KEYGRIP_ID="$(echo "$line" | sed -r 's/grp|://g')"
/usr/lib/gnupg/gpg-preset-passphrase --preset -P $KEY_PW $KEYGRIP_ID
fi
done <<< $lines
# Trust the key
touch /tmp/test.txt
gpg -a --encrypt -r $KEY_ID --trust-model always --batch --yes /tmp/test.txt
echo "trusted-key $KEY_ID" >> ~/.gnupg/gpg.conf
# Initialize the password store
sudo apt-get update
sudo apt-get install -y pass
pass init $KEY_ID &>/dev/null
- name: Checkout ${{ matrix.folder_name }} repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ matrix.github_repo }}
path: support/src/${{ matrix.folder_name }}
token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
ref: ${{ matrix.boundary_branch }}
- name: GH fix for localhost resolution
run: |
if [[ "${{ github.repository }}" == "hashicorp/boundary-ui" ]]; then
cat /etc/hosts && echo "-----------"
sudo sed -i 's/::1 *localhost ip6-localhost ip6-loopback/::1 ip6 -localhost ip6-loopback/g' /etc/hosts
cat /etc/hosts
ssh -V
fi
- name: Set git config
run: |
git config --global url."https://oauth2:${{ secrets.ELEVATED_GITHUB_TOKEN }}@github.com".insteadOf "https://github.com"
- name: Install Dependencies and Browsers
run: |
# Block Playwright from doing anything during the pnpm install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pnpm install --frozen-lockfile
cd e2e-tests
# Install browsers and dependencies based on the repository
if [[ "${{ github.repository }}" == "hashicorp/boundary-ui" ]]; then
pnpm playwright install --with-deps
elif [[ "${{ github.repository }}" == "hashicorp/boundary-ui-enterprise" ]]; then
# Use raw apt-get to install system libraries without npx
sudo apt-get install -y \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libdbus-1-3 \
libxcb1 \
libxkbcommon0 \
libx11-6 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libpango-1.0-0 \
libcairo2 \
libasound2 \
libgtk-4-1 \
libgraphene-1.0-0 \
libevent-2.1-7 \
libopus0 \
libgstreamer-plugins-base1.0-0 \
libgstreamer-plugins-good1.0-0 \
libgstreamer-gl1.0-0 \
libgstreamer-plugins-bad1.0-0 \
libflite1 \
libwebpdemux2 \
libavif13 \
libwebpmux3 \
libmanette-0.2-0 \
libenchant-2-2 \
libhyphen0 \
libsecret-1-0 \
libwoff1 \
libx264-163 \
libsoup-3.0-0 \
gstreamer1.0-libav \
libicu70 \
libegl1 \
libepoxy0 \
libevdev2 \
libffi7 \
libfontconfig1 \
libfreetype6 \
libgdk-pixbuf-2.0-0 \
libgles2 \
libglib2.0-0 \
libglx0 \
libgstreamer1.0-0 \
libgudev-1.0-0 \
libharfbuzz-icu0 \
libharfbuzz0b \
libjpeg-turbo8 \
liblcms2-2 \
libnotify4 \
libopengl0 \
libopenjp2-7 \
libpng16-16 \
libproxy1v5 \
libwayland-client0 \
libwayland-egl1 \
libwayland-server0 \
libxml2 \
libxslt1.1 \
libatomic1
# Install the browser executables
pnpm playwright install
fi
- name: Determine Go version
id: get-go-version
run: |
echo "Building with Go $(cat ./support/src/${{matrix.folder_name}}/.go-version)"
echo "go-version=$(cat ./support/src/${{matrix.folder_name}}/.go-version)" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ steps.get-go-version.outputs.go-version }}
cache: false
- name: Set up test infra
id: infra
run: |
ssh-keygen -N '' -t ed25519 -f ~/.ssh/github_enos
mkdir -p ./enos/terraform-plugin-cache
if [[ "${{ github.repository }}" == "hashicorp/boundary-ui" ]]; then
echo ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} > ./support/src/${{matrix.folder_name}}/internal/ui/VERSION
export ENOS_VAR_ui_build_override="oss"
elif [[ "${{ github.repository }}" == "hashicorp/boundary-ui-enterprise" ]]; then
echo ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} > ./support/src/${{matrix.folder_name}}/internal/ui/VERSION_ent
export ENOS_VAR_ui_build_override="enterprise"
fi
export ENOS_VAR_boundary_edition=${{ matrix.boundary_edition_short }} && \
export ENOS_VAR_enos_user=$GITHUB_ACTOR && \
export ENOS_VAR_aws_ssh_private_key_path=~/.ssh/github_enos && \
export ENOS_VAR_boundary_license="${{ secrets.BOUNDARY_ENT_LICENSE }}" && \
enos scenario launch --timeout 60m0s --chdir ./support/src/${{matrix.folder_name}}/enos ${{matrix.enos_scenario}} builder:local
- name: Move boundary binary
run: |
if [[ "${{ github.repository }}" == "hashicorp/boundary-ui" ]]; then
mv ./support/src/${{matrix.folder_name}}/bin/boundary /usr/local/bin/
elif [[ "${{ github.repository }}" == "hashicorp/boundary-ui-enterprise" ]]; then
mv ./support/src/${{matrix.folder_name}}/bin/boundary $HOME/bin
fi
boundary version
- name: Run Tests
run: |
source <(bash ./support/src/${{matrix.folder_name}}/enos/scripts/test_e2e_env.sh)
cd e2e-tests
pnpm run ${{ matrix.test_command }} --project=${{ matrix.browser}} --reporter=html
- name: Upload Playwright report
if: ${{ failure() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-report-${{ matrix.boundary_edition }}-${{ matrix.browser }}
path: e2e-tests/playwright-report
- name: Clean up test infra
if: ${{ always() }}
continue-on-error: true
run: |
export ENOS_VAR_boundary_edition=${{ matrix.boundary_edition_short }} && \
export ENOS_VAR_enos_user=$GITHUB_ACTOR && \
export ENOS_VAR_aws_ssh_private_key_path=~/.ssh/github_enos && \
enos scenario destroy --timeout 60m0s --chdir ./support/src/${{matrix.folder_name}}/enos ${{matrix.enos_scenario}} builder:local
- name: Send Slack message on failure
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
if: ${{ failure() && github.repository == 'hashicorp/boundary-ui-enterprise' }}
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: ":x: admin ui e2e tests (${{ matrix.boundary_edition }}:${{ matrix.browser }}) failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Branch:* ${{ github.repository }}:${{ github.head_ref || github.ref_name }}"