feat(testing): automate PR checks with trace based tests #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Cluster | |
on: pull_request | |
jobs: | |
create-cluster: | |
runs-on: ubuntu-latest | |
env: | |
TRACETEST_LICENSE: ${{ secrets.TRACETEST_ONPREM_TEST_LICENSE }} | |
AGENT_API_KEY: ${{ secrets.AGENT_API_KEY }} | |
AGENT_ENV_ID: ${{ secrets.AGENT_ENV_ID }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup KinD | |
uses: helm/kind-action@v1 | |
with: | |
cluster_name: tracetest | |
# install_only: true | |
- name: Test public images | |
run: | | |
kubectl config get-contexts | |
./scripts/setup_kind_cluster.sh --ci --build-deps --install-demo --force-setup | |
helm upgrade --install cloudagent ./charts/tracetest-agent \ | |
-n default \ | |
--set agent.apiKey="$AGENT_API_KEY" \ | |
--set agent.environmentId="$AGENT_ENV_ID" | |
kubectl wait --for=condition=available --timeout=60s deployment/cloudagent-tracetest-agent | |
echo "Cloudagent deployed" | |
kubectl wait --for=condition=available --timeout=60s deployment/tt-tracetest-core-api | |
- name: Configure Tracetest CLI | |
uses: kubeshop/tracetest-github-action@v1 | |
with: | |
token: ${{secrets.TRACETEST_CLI_TOKEN}} | |
# playwright is required to run the script | |
# that sets up the initial org/env and gathers the token etc | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Pull Trace based test definitions | |
env: | |
TRACETEST_TEST_REPO_CLONE_PAT: ${{ secrets.TRACETEST_TEST_REPO_CLONE_PAT }} | |
TRACETEST_TEST_REPO: ${{ secrets.TRACETEST_TEST_REPO }} | |
GH_USERNAME: ${{ secrets.TRACETEST_USER_GH_USERNAME }} | |
GH_PASSWORD: ${{ secrets.TRACETEST_USER_GH_PASSWORD }} | |
GH_SECRET: ${{ secrets.TRACETEST_USER_GH_SECRET }} | |
OUTPUT_TOKEN_FILE: "/tmp/token.json" | |
run: | | |
BASEDIR=$(pwd) | |
TESTS_REPO_DIR="/tmp/tests" | |
TESTS_DIR="$TESTS_REPO_DIR/testing" | |
# setup custom DNS resolve | |
sudo echo "127.0.0.1 tracetest.localdev" | sudo tee -a /etc/hosts | |
sudo echo "127.0.0.1 pokeshop.localdev" | sudo tee -a /etc/hosts | |
# sparse checkout of the testing directory | |
git clone --depth 1 --filter=blob:none --sparse https://[email protected]/$TRACETEST_TEST_REPO.git $TESTS_REPO_DIR | |
cd $TESTS_REPO_DIR | |
git sparse-checkout init --cone | |
git sparse-checkout set testing | |
pwd | |
tree | |
cat e2e-tracetesting/tests/setup/extract-default-token.setup.ts | |
npx playwright test e2e-tracetesting/tests/setup/extract-default-token.setup.ts --grep '@manual' | |
############################################ | |
############################################ | |
cd $BASEDIR | |
# run script for initial configuration | |
cat $OUTPUT_TOKEN_FILE | |
cat $OUTPUT_TOKEN_FILE | jq | |
tracetest run testsuite -f $TESTS_DIR/server-tracetesting --vars ./tests/vars/ci.yaml |