almalinux-compose-test-arm64 #309
This file contains hidden or 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: almalinux-compose-test-arm64 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_major: | |
| description: 'AlmaLinux major version' | |
| required: true | |
| default: '10' | |
| type: choice | |
| options: | |
| - 10-kitten | |
| - 10 | |
| - 9 | |
| - 8 | |
| pungi_repository: | |
| description: 'Add pungi repositories' | |
| type: boolean | |
| pulp_repository: | |
| description: 'Add pulp repositories' | |
| type: boolean | |
| default: true | |
| disable_default_repos: | |
| description: 'Disable system default repositories' | |
| type: boolean | |
| default: false | |
| rerun_failed: | |
| description: 'Re-run failed tests' | |
| type: boolean | |
| default: true | |
| jobs: | |
| start-runner: | |
| timeout-minutes: 10 # normally it only takes 1-2 minutes | |
| name: Setup and start self-hosted EC2 runner | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| actions: write | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4.0.2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Get AlmaLinux ${{ inputs.version_major }} aarch64 AMI most recent ID | |
| run: | | |
| os_version="${{ inputs.version_major }}" | |
| if [[ "${os_version}" == "10-kitten" ]]; then | |
| os_version="Kitten 10" | |
| fi | |
| AMI_ID=$(aws ec2 describe-images --owners 764336703387 --query "Images | max_by(@, &CreationDate) | ImageId" --filters "Name=name,Values=AlmaLinux OS ${os_version}*aarch64" --region ${{ secrets.AWS_REGION }} --output text) | |
| if [[ "${AMI_ID}" == "" || "${AMI_ID}" == "None" ]]; then | |
| echo "[Error] Failed to get AMI ID for AlmaLinux ${os_version} aarch64." | |
| exit 1 | |
| else | |
| echo "[Debug] AMI ID: '${AMI_ID}'" | |
| fi | |
| echo "AMI_ID=${AMI_ID}" >> $GITHUB_ENV | |
| - name: Setup and start runner | |
| id: start-ec2-runner | |
| uses: NextChapterSoftware/ec2-action-builder@v1.5 | |
| with: | |
| github_token: ${{ secrets.GIT_HUB_TOKEN }} | |
| aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws_region: ${{ secrets.AWS_REGION }} | |
| ec2_ami_id: ${{ env.AMI_ID }} | |
| ec2_subnet_id: ${{ secrets.EC2_SUBNET_ID}} | |
| ec2_security_group_id: ${{ secrets.EC2_SECURITY_GROUP_ID }} | |
| ec2_instance_type: t4g.large # 2 vCPU and 8 GiM Memory are enough to run tests | |
| ec2_root_disk_size_gb: "16" # override default size which is too small for actions and tests stuff | |
| ec2_root_disk_ebs_class: "gp3" # use faster and cheeper storage instead of default 'gp2' | |
| ec2_instance_ttl: 120 # Optional (default is 60 minutes) | |
| ec2_spot_instance_strategy: None # Other options are: SpotOnly, BestEffort, MaxPerformance | |
| ec2_instance_tags: > # Required for IAM role resource permission scoping | |
| [ | |
| {"Key": "Project", "Value": "GitHub Actions Self-hosted Runners"} | |
| ] | |
| compose-test: | |
| name: AlmaLinux ${{ inputs.version_major }} | |
| runs-on: ${{ github.run_id }} | |
| needs: start-runner # required to start the main job when the runner is ready | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Prepare stuff | |
| run: | | |
| # Environment variables | |
| pungi_latest_result=latest_result_almalinux | |
| pulp_root=${{ inputs.version_major }} | |
| tmt_options= | |
| rpm_gpg_key=/etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux | |
| release_version=${{ inputs.version_major }} | |
| dnf_crb_repo='CRB' | |
| dnf_extras_repo='extras' | |
| case ${{ inputs.version_major }} in | |
| 8) | |
| dnf_crb_repo='PowerTools' | |
| ;; | |
| 9) | |
| tmt_options='--feeling-safe' | |
| rpm_gpg_key="${rpm_gpg_key}-9" | |
| ;; | |
| 10) | |
| tmt_options='--feeling-safe' | |
| rpm_gpg_key="${rpm_gpg_key}-10" | |
| ;; | |
| 10-kitten) | |
| release_version=10 | |
| pulp_root=kitten-10 | |
| pungi_latest_result="${pungi_latest_result}-kitten" | |
| tmt_options='--feeling-safe' | |
| rpm_gpg_key="${rpm_gpg_key}-10" | |
| dnf_extras_repo='extras-common' | |
| ;; | |
| esac | |
| # Release major version | |
| echo "release_version=${release_version}" >> $GITHUB_ENV | |
| # Pulp repository root of the release | |
| echo "pulp_root=${pulp_root}" >> $GITHUB_ENV | |
| # Pungi repository latest results directory | |
| echo "pungi_latest_result=${pungi_latest_result}" >> $GITHUB_ENV | |
| # Name of repository to enable (PowerTools/CRB) | |
| if [ "x${{ inputs.pulp_repository }}" = "xtrue" ]; then | |
| # Lowercase the name for path in pulp's URL | |
| pulp_crb_repo="${dnf_crb_repo,,}" | |
| fi | |
| echo "dnf_crb_repo=${dnf_crb_repo}" >> $GITHUB_ENV | |
| echo "pulp_crb_repo=${pulp_crb_repo}" >> $GITHUB_ENV | |
| echo "dnf_extras_repo=${dnf_extras_repo}" >> $GITHUB_ENV | |
| # TMT extra options | |
| echo "tmt_options=${tmt_options}" >> $GITHUB_ENV | |
| # RPM_GPG_KEY file | |
| echo "rpm_gpg_key=${rpm_gpg_key}" >> $GITHUB_ENV | |
| # TMT tests run directory | |
| echo "tmt_run_dir=/var/tmp/tmt/run-001" >> $GITHUB_ENV | |
| # For nvidia drivers tests | |
| case ${{ inputs.version_major }} in | |
| 8) | |
| nvidia=false | |
| ;; | |
| *) | |
| nvidia=true | |
| ;; | |
| esac | |
| echo "nvidia=${nvidia}" >> $GITHUB_ENV | |
| - name: Create AlmaLinux pungi repository | |
| if: inputs.pungi_repository | |
| run: | | |
| cat <<'EOF'>/etc/yum.repos.d/almalinux-pungi.repo | |
| [almalinux-${{ env.release_version }}-appstream-pungi] | |
| baseurl = http://aarch64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/AppStream/$arch/os/ | |
| enabled = 1 | |
| name = almalinux-${{ env.release_version }}-appstream-pungi | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| [almalinux-${{ env.release_version }}-baseos-pungi] | |
| baseurl = http://aarch64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/BaseOS/$arch/os/ | |
| enabled = 1 | |
| name = almalinux-${{ env.release_version }}-baseos-pungi | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| [almalinux-${{ env.release_version }}-${{ env.dnf_crb_repo }}-pungi] | |
| baseurl = http://aarch64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/${{ env.dnf_crb_repo }}/$arch/os/ | |
| enabled = 1 | |
| name = almalinux-${{ env.release_version }}-${{ env.dnf_crb_repo }}-pungi | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| [almalinux-${{ env.release_version }}-${{ env.dnf_extras_repo }}-pungi] | |
| baseurl = http://aarch64-pungi-${{ env.release_version }}.almalinux.dev/almalinux/${{ env.release_version }}/$arch/${{ env.pungi_latest_result }}/compose/${{ env.dnf_extras_repo }}/$arch/os/ | |
| enabled = 1 | |
| name = almalinux-${{ env.release_version }}-${{ env.dnf_extras_repo }}-pungi | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| EOF | |
| - name: Create AlmaLinux pulp repository | |
| if: inputs.pulp_repository | |
| run: | | |
| cat <<'EOF'>/etc/yum.repos.d/almalinux-pulp.repo | |
| [almalinux-${{ env.pulp_root }}-appstream-pulp] | |
| baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-appstream-$arch/ | |
| enabled = 1 | |
| name = almalinux-${{ env.pulp_root }}-appstream-pulp | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| [almalinux-${{ env.pulp_root }}-baseos-pulp] | |
| baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-baseos-$arch/ | |
| enabled = 1 | |
| name = almalinux-${{ env.pulp_root }}-baseos-pulp | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| [almalinux-${{ env.pulp_root }}-${{ env.pulp_crb_repo }}-pulp] | |
| baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-${{ env.pulp_crb_repo }}-$arch/ | |
| enabled = 1 | |
| name = almalinux-${{ env.pulp_root }}-${{ env.pulp_crb_repo }}-pulp | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| [almalinux-${{ env.pulp_root }}-${{ env.dnf_extras_repo }}-pulp] | |
| baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-${{ env.dnf_extras_repo }}-$arch/ | |
| enabled = 1 | |
| name = almalinux-${{ env.pulp_root }}-${{ env.dnf_extras_repo }}-pulp | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| EOF | |
| - name: Create AlmaLinux nvidia pulp repository | |
| if: env.nvidia == 'true' && inputs.pulp_repository | |
| run: | | |
| cat <<'EOF'>/etc/yum.repos.d/almalinux-nvidia-pulp.repo | |
| [almalinux-${{ env.pulp_root }}-nvidia-pulp] | |
| baseurl = https://build.almalinux.org/pulp/content/prod/almalinux-${{ env.pulp_root }}-nvidia-$arch/ | |
| enabled = 1 | |
| name = almalinux-${{ env.pulp_root }}-nvidia-pulp | |
| gpgkey=file://${{ env.rpm_gpg_key }} | |
| EOF | |
| - name: Update the system | |
| run: | | |
| sudo dnf -y clean all | |
| sudo dnf -y update | |
| - name: Get system release | |
| run: | | |
| echo "system_release=$(cat /etc/almalinux-release)" >> $GITHUB_ENV | |
| - name: Prepare test infrastructure | |
| run: | | |
| enable_repo=${{ env.dnf_crb_repo }} | |
| dnf_opts="--enablerepo=${enable_repo,,}" | |
| if [ "${{ inputs.disable_default_repos }}" = "true" ]; then | |
| # Disable all enabled system repositories | |
| for enabled_repo in $(sudo dnf repolist --enabled | awk '/repo id/ {A=1; next} A {print $1}' | grep -v -E 'pungi|pulp'); do | |
| echo "[Debug] Disable '${enabled_repo}' repository" | |
| sudo dnf config-manager --set-disabled ${enabled_repo} | |
| done | |
| dnf_opts= | |
| fi | |
| case ${{ inputs.version_major }} in | |
| 10-kitten) | |
| sudo dnf install -y ${dnf_opts} epel-release almalinux-kitten-release-devel | |
| [ "${{ inputs.disable_default_repos }}" = "false" ] && \ | |
| dnf_opts="${dnf_opts} --enablerepo=devel" | |
| sudo dnf install -y ${dnf_opts} python3-pip beakerlib initscripts-service | |
| sudo sh -c 'export PATH=$PATH:/usr/local/bin; pip install flexparser==0.3.1 tmt' | |
| ;; | |
| 10) | |
| sudo dnf install -y ${dnf_opts} epel-release | |
| sudo dnf install -y ${dnf_opts} python3-pip beakerlib initscripts-service | |
| sudo sh -c 'export PATH=$PATH:/usr/local/bin; pip install flexparser==0.3.1 tmt' | |
| ;; | |
| 9) | |
| sudo dnf install -y ${dnf_opts} epel-release | |
| sudo dnf install -y ${dnf_opts} tmt initscripts-service | |
| ;; | |
| *) | |
| sudo dnf install -y ${dnf_opts} epel-release | |
| sudo dnf install -y ${dnf_opts} tmt tmt-report-html | |
| ;; | |
| esac | |
| echo "[Debug] $(sudo sh -c 'export PATH=$PATH:/usr/local/bin; tmt --version')" | |
| - name: Run tests | |
| id: run-tests | |
| continue-on-error: true | |
| run: sudo sh -c 'export pungi_repository=${{ inputs.pungi_repository }}; export pulp_repository=${{ inputs.pulp_repository }}; export PATH=$PATH:/usr/local/bin; tmt -vvv -c distro=centos-stream-${{ env.release_version }} run --all provision --how=local ${{ env.tmt_options }}' | |
| - name: ${{ inputs.version_major }} tests results | |
| run: | | |
| #[Debug] | |
| sudo find ${{ env.tmt_run_dir }}/plans/*/execute -name "results.yaml" -exec cat {} \; | |
| sudo find ${{ env.tmt_run_dir }}/plans/*/execute -name "results.yaml" -exec sh -c 'cp -av "$1" "${{ github.action_path }}/$(basename "$(dirname "$(dirname $1)")").results.yaml"' _ {} \; | |
| - name: ${{ inputs.version_major }} tests log | |
| run: | | |
| #[Debug] | |
| sudo cat ${{ env.tmt_run_dir }}/log.txt | |
| sudo /bin/cp -av ${{ env.tmt_run_dir }}/log.txt ${{github.action_path}}/log.txt | |
| - name: ${{ inputs.version_major }} tests output | |
| run: | | |
| cd ${{ env.tmt_run_dir }}/ | |
| tar cf ${{github.action_path}}/output.tar $( find . -name output.txt ) || true | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: Tests log | |
| path: ${{github.action_path}}/log.txt | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: Tests results | |
| path: ${{github.action_path}}/*.results.yaml | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: Tests output | |
| path: ${{github.action_path}}/output.tar | |
| - name: Get list of failed tests | |
| if: job.steps.run-tests.status == failure() | |
| run: | | |
| # Install 'yq' | |
| sudo curl -L -o /usr/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 | |
| sudo chmod +x /usr/bin/yq | |
| sudo /usr/bin/yq --version | |
| # Create failed tests list | |
| yq --no-doc '.[] | select(.result == "fail" or .result == "error") | .name' \ | |
| $(sudo find ${{ env.tmt_run_dir }}/plans/*/execute -name results.yaml | xargs) \ | |
| > ${{ env.tmt_run_dir }}/tests_failed.txt | |
| echo "[Debug] failed tests:" | |
| echo "$(cat ${{ env.tmt_run_dir }}/tests_failed.txt)" | |
| - name: Re-run failed tests, prepare tests summary | |
| if: job.steps.run-tests.status == failure() | |
| run: | | |
| # Tests results and the step exit code | |
| rerun_results= | |
| exit_code=0 | |
| # Read failed tests list | |
| for test_failed in $(cat ${{ env.tmt_run_dir }}/tests_failed.txt | xargs); do | |
| echo "[Debug] Re-run '${test_failed}'" | |
| # Include failed test name into results summary | |
| test_result="${test_failed}" | |
| # Re-run specific failed test | |
| if [ "${{ inputs.rerun_failed }}" = "true" ]; then | |
| if sudo sh -c "export pungi_repository=${{ inputs.pungi_repository }}; export pulp_repository=${{ inputs.pulp_repository }}; export PATH=$PATH:/usr/local/bin; tmt -vvv -c distro=centos-stream-${{ env.release_version }} run --all provision --how=local ${{ env.tmt_options }} test --name ${test_failed}"; then | |
| test_result="${test_failed} [re-run ✅]" | |
| else | |
| test_result="${test_failed} [re-run ❌]" | |
| exit_code=1 | |
| fi | |
| else | |
| echo "[Debug]" | |
| echo "If without re-run, fail this step as the '${test_failed}' test previously failed." | |
| exit_code=1 | |
| fi | |
| # Format test results in list format: 'item1', 'item2', ... | |
| [ "x${rerun_results}" = "x" ] && rerun_results="'${test_result}'" || rerun_results="${rerun_results}, '${test_result}'" | |
| done | |
| # Export header and test results | |
| [ "x${rerun_results}" = "x" ] && summary_header="✅ All tests pass." || summary_header="❌ Failed tests:" | |
| echo "rerun_results=${rerun_results}" >> $GITHUB_ENV | |
| echo "summary_header=${summary_header}" >> $GITHUB_ENV | |
| exit $exit_code | |
| - name: Print tests summary | |
| if: job.steps.run-tests.status == failure() || failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| result-encoding: string | |
| script: | | |
| core.summary | |
| .addHeading('${{ env.system_release }}', '4') | |
| .addHeading('Used repositories:', '4') | |
| .addList(['pulp - ${{ inputs.pulp_repository && '✅' || '❌'}}','pungi - ${{ inputs.pungi_repository && '✅' || '❌'}}','default repos - ${{ inputs.disable_default_repos && '❌' || '✅'}}'], true) | |
| .addHeading('${{ env.summary_header }}', '4') | |
| .addList([${{ env.rerun_results }}], true) | |
| .write() |