Skip to content

Commit

Permalink
Move linux arm into it's own matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Jan 21, 2025
1 parent 8c44f36 commit 2c47a91
Show file tree
Hide file tree
Showing 2 changed files with 374 additions and 21 deletions.
318 changes: 317 additions & 1 deletion .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,323 @@ jobs:
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.matrix)['linux'] }}
include: ${{ fromJSON(inputs.matrix)['linux-x86_64'] }}
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: "${{ inputs.python-version }}"

- name: "Throttle Builds"
shell: bash
run: |
t=$(python3 -c 'import random, sys; sys.stdout.write(str(random.randint(1, 15)))'); echo "Sleeping $t seconds"; sleep "$t"
- name: "Set `TIMESTAMP` environment variable"
shell: bash
run: |
echo "TIMESTAMP=$(date +%s)" | tee -a "$GITHUB_ENV"
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Free Disk Space Before Build
run: |
echo "Disk space before cleanup:"
df -h
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "Disk space after cleanup:"
df -h
- name: Setup Salt Version
run: |
echo "${{ inputs.salt-version }}" > salt/_version.txt
- name: Download Onedir Tarball as an Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ matrix.platform }}-${{ matrix.arch }}.tar.xz
path: artifacts/

- name: Decompress Onedir Tarball
shell: bash
run: |
python3 -c "import os; os.makedirs('artifacts', exist_ok=True)"
cd artifacts
tar xvf ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ matrix.platform }}-${{ matrix.arch }}.tar.xz
- name: "Configure docker"
run: |
sudo sed -i '/LimitNOFILE=infinity/c\LimitNOFILE=1048576' /lib/systemd/system/containerd.service
sudo systemctl daemon-reload
sudo systemctl restart containerd
cat /lib/systemd/system/containerd.service
- name: "Pull container ${{ matrix.container }}"
run: |
docker pull ${{ matrix.container }}
- name: "Create docker network"
run: |
docker network create -o "com.docker.network.driver.mtu=1500" --ipv6 --subnet 2001:db8::/64 ip6net
- name: "Host network config"
run: |
ip a
- name: Free Memory Before Container
shell: bash
run: |
free -h
- name: "Create container ${{ matrix.container }}"
run: |
/usr/bin/docker \
create --name ${{ github.run_id }}_salt-test \
--workdir /__w/salt/salt \
--privileged \
--ulimit="nofile=262144:262144" \
-e "HOME=/github/home" \
-e GITHUB_ACTIONS=true \
-e CI=true \
-e SKIP_REQUIREMENTS_INSTALL=1 \
-e PRINT_TEST_SELECTION=0 \
-e PRINT_TEST_PLAN_ONLY=0 \
-e PRINT_SYSTEM_INFO=0 \
-e RERUN_FAILURES=1 \
-e GITHUB_ACTIONS_PIPELINE=1 \
-e SKIP_INITIAL_ONEDIR_FAILURES=1 \
-e SKIP_INITIAL_GH_ACTIONS_FAILURES=1 \
-e SKIP_CODE_COVERAGE=${{ inputs.skip-code-coverage && '1' || '0' }} \
-e CONVERAGE_CONTEXT=${{ matrix.slug }} \
-e COLUMNS=190 \
-e PIP_INDEX_URL=${{ vars.PIP_INDEX_URL }} \
-e PIP_TRUSTED_HOST=${{ vars.PIP_TRUSTED_HOST }} \
-e PIP_EXTRA_INDEX_URL=${{ vars.PIP_EXTRA_INDEX_URL }} \
-e PIP_DISABLE_PIP_VERSION_CHECK="1" \
-e RAISE_DEPRECATIONS_RUNTIME_ERRORS="1" \
-e SALT_TRANSPORT=${{ matrix.transport }} \
-e LANG="en_US.UTF-8" \
-e SHELL=/bin/bash \
-v "/home/runner/work":"/__w" \
-v "/tmp/":"/var/lib/docker" \
--entrypoint "/usr/lib/systemd/systemd" \
${{ matrix.container }} \
--systemd --unit rescue.target
- name: "Start container ${{ matrix.container }}"
run: |
/usr/bin/docker start ${{ github.run_id }}_salt-test
- name: "Show container inspect ${{ matrix.container }}"
run: |
/usr/bin/docker inspect ${{ github.run_id }}_salt-test
- name: Download nox.linux.${{ matrix.arch }}.tar.* artifact for session ${{ inputs.nox-session }}
uses: actions/download-artifact@v4
with:
name: nox-linux-${{ matrix.arch }}-${{ inputs.nox-session }}

- name: Install Nox
run: |
python3 -m pip install 'nox==${{ inputs.nox-version }}'
env:
PIP_INDEX_URL: https://pypi.org/simple

- name: Decompress .nox Directory
run: |
docker exec ${{ github.run_id}}_salt-test python3 -m nox --force-color -e decompress-dependencies -- linux ${{ matrix.arch }}
- name: Download testrun-changed-files.txt
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' }}
uses: actions/download-artifact@v4
with:
name: testrun-changed-files.txt

- name: Current Directory
run: |
pwd
- name: Show System Info
run: |
docker exec -e SKIP_REQUIREMENTS_INSTALL=1 -e PRINT_SYSTEM_INFO_ONLY=1 ${{ github.run_id}}_salt-test \
python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }}
- name: Free Space on Host
shell: bash
run: |
df -h
- name: Show container network info
shell: bash
run: |
docker exec ${{ github.run_id}}_salt-test ip addr
- name: Show container processes
shell: bash
run: |
docker exec ${{ github.run_id}}_salt-test ps auxf
- name: Free Space on Container
shell: bash
run: |
docker exec ${{ github.run_id}}_salt-test df -h
- name: Free Memory
shell: bash
run: |
free -h
- name: Configure apparmor
run: |
# Apparmor's unix-chkpwd profile gets in the way of tests needing to
# authenticate from inside a container.
cat <<'EOF' | sudo tee /etc/apparmor.d/unix-chkpwd
abi <abi/4.0>,
include <tunables/global>
profile unix-chkpwd /{,usr/}{,s}bin/unix_chkpwd flags=(unconfined) {
include <abstractions/base>
include <abstractions/nameservice>
# To write records to the kernel auditing log.
capability audit_write,
network netlink raw,
/{,usr/}{,s}bin/unix_chkpwd mr,
/etc/shadow r,
# systemd userdb, used in nspawn
/run/host/userdb/*.user r,
/run/host/userdb/*.user-privileged r,
# file_inherit
owner /dev/tty[0-9]* rw,
include if exists <local/unix-chkpwd>
}
EOF
sudo systemctl restart apparmor
sudo aa-status
- name: Run Changed Tests
id: run-fast-changed-tests
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' }}
run: |
docker exec ${{ github.run_id}}_salt-test python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- \
--core-tests --slow-tests --suppress-no-test-exit-code --from-filenames=testrun-changed-files.txt
- name: Run Fast Tests
id: run-fast-tests
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['fast'] }}
run: |
docker exec ${{ github.run_id}}_salt-test \
python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- \
--suppress-no-test-exit-code
- name: Run Slow Tests
id: run-slow-tests
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['slow'] }}
run: |
docker exec ${{ github.run_id}}_salt-test \
python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- \
--suppress-no-test-exit-code --no-fast-tests --slow-tests
- name: Run Core Tests
id: run-core-tests
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['core'] }}
run: |
docker exec ${{ github.run_id}}_salt-test \
python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- \
--suppress-no-test-exit-code --no-fast-tests --core-tests
- name: Run Flaky Tests
id: run-flaky-tests
if: ${{ fromJSON(inputs.testrun)['selected_tests']['flaky'] }}
run: |
docker exec ${{ github.run_id}}_salt-test \
python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- \
--suppress-no-test-exit-code --no-fast-tests --flaky-jail
- name: Run Full Tests
id: run-full-tests
if: ${{ fromJSON(inputs.testrun)['type'] == 'full' }}
run: |
docker exec ${{ github.run_id}}_salt-test \
python3 -m nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- \
--slow-tests --core-tests --test-group-count=${{ matrix.test-group-count || 1 }} --test-group=${{ matrix.test-group || 1 }}
- name: Stop Container
run: |
docker container stop ${{ github.run_id}}_salt-test
- name: Remove Container
run: |
docker container rm ${{ github.run_id}}_salt-test
- name: Remove Container Image
run: |
docker image rm ${{ matrix.container }}
- name: Fix file ownership
run: |
sudo chown -R "$(id -un)" .
- name: Combine Coverage Reports
if: always() && inputs.skip-code-coverage == false
run: |
nox --force-color -e combine-coverage
- name: Prepare Test Run Artifacts
id: download-artifacts-from-vm
if: always()
run: |
# Delete the salt onedir, we won't need it anymore and it will prevent
# from it showing in the tree command below
sudo rm -rf artifacts/salt*
tree -a artifacts
if [ "${{ inputs.skip-code-coverage }}" != "true" ]; then
mv artifacts/coverage/.coverage artifacts/coverage/.coverage.${{ matrix.slug }}.${{ inputs.nox-session }}.${{ matrix.transport }}.${{ matrix.tests-chunk }}
fi
- name: Upload Code Coverage Test Run Artifacts
if: always() && inputs.skip-code-coverage == false && steps.download-artifacts-from-vm.outcome == 'success' && job.status != 'cancelled'
uses: actions/upload-artifact@v4
with:
name: testrun-coverage-artifacts-${{ matrix.slug }}-${{ inputs.nox-session }}-${{ matrix.transport }}-${{ matrix.tests-chunk }}-${{ env.TIMESTAMP }}
path: |
artifacts/coverage/
include-hidden-files: true

- name: Upload JUnit XML Test Run Artifacts
if: always() && steps.download-artifacts-from-vm.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: testrun-junit-artifacts-${{ matrix.slug }}-${{ inputs.nox-session }}-${{ matrix.transport }}${{ matrix.fips && '(fips)' || '' }}-${{ matrix.tests-chunk }}-${{ matrix.test-group || 1 }}-${{ env.TIMESTAMP }}
path: |
artifacts/xml-unittests-output/
include-hidden-files: true

- name: Upload Test Run Log Artifacts
if: always() && steps.download-artifacts-from-vm.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: testrun-log-artifacts-${{ matrix.slug }}-${{ inputs.nox-session }}-${{ matrix.transport }}${{ matrix.fips && '(fips)' || '' }}-${{ matrix.tests-chunk }}-${{ matrix.test-group || 1 }}-${{ env.TIMESTAMP }}
path: |
artifacts/logs
include-hidden-files: true

test-linux-arm64:
name: ${{ matrix.display_name }} ${{ matrix.tests-chunk }} ${{ matrix.transport }}${{ matrix.fips && '(fips)' || '' }}${{ matrix.test-group && ' ' || '' }}${{ matrix.test-group && matrix.test-group || '' }}
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-22.04' || inputs.linux_arm_runner }}
if: ${{ toJSON(fromJSON(inputs.matrix)['linux']) != '[]' }}
# Full test runs. Each chunk should never take more than 2 hours.
# Partial test runs(no chunk parallelization), 6 Hours
timeout-minutes: ${{ fromJSON(inputs.testrun)['type'] == 'full' && inputs.default-timeout || 360 }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.matrix)['linux-arm64'] }}
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
Expand Down
Loading

0 comments on commit 2c47a91

Please sign in to comment.