package-test-pipeline #10
Workflow file for this run
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: package-test-pipeline | |
on: | |
workflow_dispatch: | |
inputs: | |
package_testing_branch: | |
description: "Target branch for package-testing repository" | |
type: string | |
default: "master" | |
required: true | |
pmm_server_image: | |
description: "pmm-server docker image, default perconalab/pmm-server:dev-latest" | |
required: false | |
type: string | |
default: "perconalab/pmm-server:dev-latest" | |
pmm_client_tarball: | |
description: "PMM Client tarball link or FB-code" | |
type: string | |
# package_repo: experimental | testing | main | pmm2-client-main | |
pmm_version: | |
description: "expected version" | |
required: false | |
type: string | |
repository: | |
description: "Select Repo for Client Nodes:" | |
required: true | |
default: "dev-latest" | |
type: choice | |
options: | |
- release | |
- release candidate | |
- patch-release candidate | |
- dev-latest | |
metrics_mode: | |
description: "Select the Metrics Mode for PMM Client:" | |
required: true | |
default: "auto" | |
type: choice | |
options: | |
- auto | |
- push | |
- pull | |
test_name: | |
description: "Target branch for package-testing repository" | |
type: string | |
default: "integration" | |
required: true | |
os: | |
description: "Select OS to run test in:" | |
required: true | |
default: "jammy-x64" | |
type: choice | |
options: | |
- bionic-x64 | |
- bullseye-x64 | |
- buster-x64 | |
- focal-x64 | |
- jammy-x64 | |
- centos-7-x64 | |
- ol-8-x64 | |
- ol-9-x64 | |
jobs: | |
test: | |
name: ${{ inputs.test_name }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 90 | |
env: | |
SHA: ${{ inputs.sha || 'null' }} | |
PACKAGE_TESTING_BRANCH: ${{ inputs.package_testing_branch || 'master' }} | |
PMM_SERVER_IMAGE: ${{ inputs.pmm_server_image }} | |
TARBALL: ${{ inputs.pmm_server_image || 'null' }} | |
EXPECTED_VERSION: ${{ inputs.pmm_version }} | |
REPO: ${{ inputs.repository || 'dev-latest' }} | |
METRICS_MODE: ${{ inputs.metrics_mode || 'auto' }} | |
PLAYBOOK: ${{ inputs.playbook }} | |
steps: | |
- name: "Create status check" | |
if: ${{ env.SHA != 'null' }} | |
uses: percona/gh-action-github-status-action@v1 | |
continue-on-error: true | |
with: | |
authToken: ${{ secrets.GITHUB_TOKEN }} | |
context: "${{ inputs.test_name }} Package test" | |
description: "Test execution ${{ job.status }}" | |
state: "pending" | |
repository: ${{ github.repository }} | |
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
sha: ${{ env.SHA }} | |
- name: 'Checkout package-testing: "${{ inputs.package_testing_branch }}"' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ inputs.package_testing_branch }} | |
- name: 'Convert choices' | |
run: | | |
### pmm-server docker image ### | |
if [[ -z "${{ env.PMM_SERVER_IMAGE }}" ]]; then | |
if [[ "${{ inputs.repository }}" = "dev-latest" ]]; then | |
echo "PMM_SERVER_IMAGE=perconalab/pmm-server:dev-latest" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.repository }}" =~ "candidate" ]]; then | |
rc_latest=$(wget -q "https://registry.hub.docker.com/v2/repositories/perconalab/pmm-client/tags?page_size=25&name=rc" -O - | jq -r .results[].name | grep 2.*.*-rc$ | sort -V | tail -n1) | |
echo "PMM_SERVER_IMAGE=perconalab/pmm-server:$rc_latest" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.repository }}" = "release" ]]; then | |
r_latest=$(wget -q https://registry.hub.docker.com/v2/repositories/percona/pmm-client/tags -O - | jq -r .results[].name | grep -v latest | sort -V | tail -n1) | |
echo "PMM_SERVER_IMAGE=percona/pmm-server:$r_latest" >> $GITHUB_ENV | |
fi | |
fi | |
echo "${{ env.PMM_SERVER_IMAGE }}" | |
### pmm2-client repository ### | |
if [[ "${{ inputs.repository }}" = "dev-latest" ]]; then | |
echo "REPO=experimental" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.repository }}" =~ "candidate" ]]; then | |
echo "REPO=testing" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.repository }}" = "release" ]]; then | |
echo "REPO=release" >> $GITHUB_ENV | |
fi | |
echo "${{ env.REPO }}" | |
### vagrant vm ### | |
if [[ "${{ inputs.os }}" =~ "buster" ]]; then | |
echo "VM_BOX=generic/debian10" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "bullseye" ]]; then | |
echo "VM_BOX=generic/debian11" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "bionic" ]]; then | |
echo "VM_BOX=generic/ubuntu1804" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "focal" ]]; then | |
echo "VM_BOX=ubuntu/focal64" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "jammy" ]]; then | |
echo "VM_BOX=generic/ubuntu2204" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "centos-7" ]]; then | |
echo "VM_BOX=testing" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "ol-8" ]]; then | |
echo "VM_BOX=generic/oracle8" >> $GITHUB_ENV | |
fi | |
if [[ "${{ inputs.os }}" =~ "ol-9" ]]; then | |
echo "VM_BOX=generic/oracle9" >> $GITHUB_ENV | |
fi | |
echo "${{ env.VM_BOX }}" | |
### test name -> playbook map ### | |
# basic -> pmm2-client.yml | |
# basic upgrade -> pmm2-client_upgrade.yml | |
# basic tarball -> pmm2-client_custom_path.yml | |
# config -> pmm2-client_integration_auth_config.yml | |
# register -> pmm2-client_integration_auth_register.yml | |
# setup -> pmm2-client_integration_auth_setup.yml | |
# integration tarball -> pmm2-client_integration_custom_path.yml | |
# integration -> pmm2-client_integration_custom_port.yml | |
# integration upgrade -> pmm2-client_integration_upgrade_custom_port.yml | |
######### Matrix tests | |
# integration -> pmm2-client_integration.yml | |
# integration upgrade -> pmm2-client_integration_upgrade.yml | |
# tarball upgrade -> pmm2-client_integration_upgrade_custom_path.yml | |
- name: 'Setup "${{ env.PMM_SERVER_IMAGE }}"' | |
run: | | |
docker create -v /srv --name pmm-server-data ${{ env.PMM_SERVER_IMAGE }} | |
docker run -d -p 80:80 -p 443:443 -p 9000:9000 \ | |
--volumes-from pmm-server-data --name pmm-server --restart always ${{ env.PMM_SERVER_IMAGE }} | |
- name: "Setup tools" | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y apt-transport-https ca-certificates ansible virtualbox vagrant | |
- name: "Wait for PMM Server to be healthy" | |
run: | | |
timeout 240 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://127.0.0.1/v1/readyz)" != "200" ]]; do sleep 2; done' || false | |
- name: "Create vagrantfile" | |
working-directory: ./ | |
run: | | |
pwd | |
# mkdir -p ~/test-vm/ | |
# cat > ~/test-vm/Vagrantfile <<EOF | |
cat > Vagrantfile <<EOF | |
Vagrant.require_version ">= 1.7.0" | |
Vagrant.configure(2) do |config| | |
config.vm.box = "${{ env.VM_BOX}}" | |
config.ssh.insert_key = false | |
config.vm.define :CLIENT_TEST do |t| | |
end | |
config.vm.synced_folder "/home/runner/work/package-testing/package-testing/", "/pmm/package-testing/" | |
config.vm.provision "shell", privileged: true, inline: <<-SHELL | |
## Set environment variables... | |
export PMM_SERVER_IP=10.0.2.2:443 | |
export METRICS_MODE=${{ env.METRICS_MODE }} | |
export PMM_VERSION="${{ env.EXPECTED_VERSION }}" | |
export install_repo=${{ env.REPO }} | |
export tarball_link=${{ env.TARBALL }} | |
### rpm | |
# sudo yum install -y epel-release | |
# sudo yum -y update | |
# sudo yum install -y ansible git wget | |
sudo apt-get install -y dirmngr gnupg2 | |
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list > /dev/null | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 | |
sudo apt update -y | |
sudo apt-get install -y ansible git wget | |
cd /pmm/package-testing/playbooks | |
ansible-playbook -vv --connection=local --inventory 127.0.0.1, --limit 127.0.0.1 pmm2-client_integration.yml | |
SHELL | |
end | |
EOF | |
- name: "Run ${{ inputs.test_name }} test on ${{ inputs.os }}" | |
working-directory: ./ | |
run: vagrant up | |
- name: "Create status check" | |
uses: percona/gh-action-github-status-action@v1 | |
if: ${{ env.SHA != 'null' && always() }} | |
continue-on-error: true | |
with: | |
authToken: ${{ secrets.GITHUB_TOKEN }} | |
context: "${{ inputs.test_name }} Package test" | |
description: "Test execution ${{ job.status }}" | |
state: ${{ job.status }} | |
repository: ${{ github.repository }} | |
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
sha: ${{ env.SHA }} |