Skip to content

ci: select Salt version based on PR labels #790

ci: select Salt version based on PR labels

ci: select Salt version based on PR labels #790

Workflow file for this run

name: Build and Test Docker Image
on:
pull_request:
types:
- assigned
- ready_for_review
- synchronize
- labeled
- unlabeled
branches:
- main
paths-ignore:
- "./**/*.md"
- "docs/"
- "social/"
- ".editorconfig"
- ".gitignore"
- ".shellcheckrc"
- "compose.yml"
- "LICENSE"
- "Makefile"
env:
BASE_IMAGE: localhost:5000/${{ github.repository }}
BASE_TAG: test-${{ github.sha }}
IMAGE_NAME: localhost:5000/${{ github.repository }}:test-${{ github.sha }}
REGISTRY_PATH: ${{ github.workspace }}/registry
jobs:
metadata:
name: Metadata
runs-on: ubuntu-24.04
outputs:
salt_type: ${{ steps.salt_type.outputs.salt_type }}
salt_version: ${{ steps.salt_version.outputs.salt_version }}
vcs_ref: ${{ steps.vcs_ref.outputs.vcs_ref }}
created_on: ${{ steps.created_on.outputs.created_on }}
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Release Type
id: salt_type
env:
LABELS: ${{ toJson(github.event.pull_request.labels) }}
run: |
source .github/workflows/ci_tools.sh
export_release_type_from_labels salt_type "$LABELS"
- name: Salt Version
id: salt_version
run: |
source .github/workflows/ci_tools.sh
export_salt_version salt_version "${{ steps.salt_type.outputs.salt_type }}"
- name: VCS Ref
id: vcs_ref
run: |
VCS_REF="${GITHUB_SHA::8}"
echo "VCS ref: ${VCS_REF}"
echo "vcs_ref=${VCS_REF}" >> ${GITHUB_OUTPUT}
- name: Created On
id: created_on
run: |
CREATED_ON="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
echo "Created on: ${CREATED_ON}"
echo "created_on=${CREATED_ON}" >> ${GITHUB_OUTPUT}
build:
name: Build
runs-on: ubuntu-24.04
needs: metadata
steps:
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Start Docker registry
run: |
docker run --rm --detach --publish 5000:5000 \
--volume ${REGISTRY_PATH}:/var/lib/registry \
--name registry registry:2
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/.buildx-cache
key: docker-cache-${{ github.event.pull_request.head.sha }}
restore-keys: |
docker-cache-${{ github.event.pull_request.head.ref }}
docker-cache-
- name: Build docker-salt-master Base Image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
VCS_REF=${{ needs.metadata.outputs.vcs_ref }}
BUILD_DATE=${{ needs.metadata.outputs.created_on }}
SALT_VERSION=${{ needs.metadata.outputs.salt_version }}
push: true
tags: ${{ env.IMAGE_NAME }}
cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max
- name: Move new cache
run: |
rm -rf ${{ runner.temp }}/.buildx-cache
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
- name: Build docker-salt-master SaltGUI Image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.gui
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
BASE_TAG=${{ env.BASE_TAG }}
push: true
tags: ${{ env.IMAGE_NAME }}-gui
- name: Stop Docker Registry
run: docker stop registry
- name: Save Registry Data for Testing
uses: actions/upload-artifact@v4
with:
name: docker-registry-data
path: ${{ env.REGISTRY_PATH }}
test:
name: Test
needs:
- build
- metadata
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
env:
SALT_VERSION: ${{ needs.metadata.outputs.salt_version }}
DOCKER_CLI_EXPERIMENTAL: enabled
BOOTUP_WAIT_SECONDS: 20
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v5
- name: Download Docker Registry Data from Build Job
uses: actions/download-artifact@v5
with:
name: docker-registry-data
path: ${{ env.REGISTRY_PATH }}
- name: Start Docker Registry
run: |
docker run --rm --detach --publish 5000:5000 \
--volume ${REGISTRY_PATH}:/var/lib/registry \
--name registry registry:2
sleep 10
- name: Import Docker Images
run: |
docker pull ${IMAGE_NAME}
docker pull ${IMAGE_NAME}-gui
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install and Configure salt-minion
run: |
# Install salt-minion from salt repos
salt_bootstrap_url="https://github.com/saltstack/salt-bootstrap/releases/latest/download/bootstrap-salt.sh"
curl -o bootstrap-salt.sh -L "${salt_bootstrap_url}"
sudo sh bootstrap-salt.sh -dXP stable
sudo systemctl stop salt-minion
sudo systemctl disable salt-minion
sudo rm -f /var/log/salt/minion
- name: Install Tests Utils
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Execute Basic Tests
if: always()
run: tests/basic/test.sh
- name: Execute Keys Mount Point Tests
if: always()
run: tests/keys-mount-point/test.sh
- name: Execute Healthcheck Tests
if: always()
run: tests/healthcheck/test.sh
- name: Execute salt-api Tests
if: always()
run: |
tests/salt-api/test.sh
tests/salt-api/salt-api-ldap.sh
- name: Execute salt-minion Tests
if: always()
run: tests/salt-minion/test.sh
- name: Execute GitFS Tests
if: always()
env:
GITFS_KEYS_DIR: tests/gitfs/data/keys/gitfs
SSH_PRIVATE_KEY: ${{ secrets.TESTS_REPO_PRIVATE_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.TESTS_REPO_PUBLIC_KEY }}
run: |
mkdir -p "${GITFS_KEYS_DIR}"
echo "${SSH_PRIVATE_KEY}" | base64 -d > "${GITFS_KEYS_DIR}"/gitfs_ssh
chmod 600 "${GITFS_KEYS_DIR}"/gitfs_ssh
echo "${SSH_PUBLIC_KEY}" | base64 -d > "${GITFS_KEYS_DIR}"/gitfs_ssh.pub
chmod 644 "${GITFS_KEYS_DIR}"/gitfs_ssh.pub
tests/gitfs/test.sh
- name: Execute config-reloader Tests
if: always()
run: tests/config-reloader/test.sh
- name: Execute GPG Tests
if: always()
run: tests/gpg/test.sh
- name: Python Extra Packages Tests
if: always()
run: tests/python-extra-packages/test.sh
- name: SaltGUI Tests
if: always()
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}-gui
run: tests/salt-api/test.sh
- name: Cleanup
if: always()
run: |
docker rm --force registry