This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
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: Run spec tests | |
on: | |
pull_request: | |
workflow_dispatch: | |
# Cancel in-progress PR verification workflows. We only care about verifying the latest commit. | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
spec_tests: | |
name: spec tests | |
runs-on: ubuntu-latest | |
container: | |
image: fedora:38 | |
options: --privileged | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
database: [postgres, mariadb] | |
mode: [standalone, hosted] | |
steps: | |
- name: Install dependencies | |
shell: bash | |
run: | | |
dnf -y --setopt install_weak_deps=False update | |
dnf --setopt install_weak_deps=False install -y gettext docker git-core | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Rebase | |
uses: ./.github/actions/rebase | |
- name: Set Environment Variables | |
uses: ./.github/actions/set_vars | |
with: | |
varFilePath: ./.github/variables/pr_verification.env | |
- name: Install docker compose | |
shell: bash | |
run: | | |
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | |
mkdir -p $DOCKER_CONFIG/cli-plugins | |
curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose | |
sudo chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | |
- name: Log in to the registry | |
if: ${{ ! github.event.pull_request.head.repo.fork }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
if: ${{ github.event.pull_request.head.repo.fork }} | |
uses: docker/setup-buildx-action@v3 | |
- if: matrix.mode == 'standalone' | |
name: Add standalone env variable | |
working-directory: ./.github/containers | |
shell: bash | |
run: | | |
echo "CANDLEPIN_STANDALONE=true" > .env | |
echo "CANDLEPIN_AUTH_CLOUD_ENABLE=false" >> .env | |
echo "MODULE_CONFIG_MANIFESTGEN_CONFIGURATION_MODULE=org.candlepin.testext.manifestgen.ManifestGeneratorModule" >> .env | |
- if: matrix.mode == 'hosted' | |
name: Add hosted env variables | |
working-directory: ./.github/containers | |
shell: bash | |
run: | | |
echo "CANDLEPIN_STANDALONE=false" > .env | |
echo "MODULE_CONFIG_HOSTEDTEST_CONFIGURATION_MODULE=org.candlepin.testext.hostedtest.HostedTestModule" >> .env | |
echo "CANDLEPIN_AUTH_CLOUD_ENABLE=true" >> .env | |
echo "MODULE_CONFIG_MANIFESTGEN_CONFIGURATION_MODULE=org.candlepin.testext.manifestgen.ManifestGeneratorModule" >> .env | |
- name: Create Candlepin and database containers | |
shell: bash | |
run: | | |
BRIDGE_NETWORK=$(docker network ls --filter=name=github_network_ --format="{{ .Name }}") | |
echo "NETWORK=$BRIDGE_NETWORK" >> ./.github/containers/.env | |
docker compose -f ./.github/containers/${{ matrix.database }}.docker-compose.yml --env-file ./.github/containers/.env up --build -d --wait | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Run Spec tests | |
uses: gradle/gradle-build-action@v3 | |
env: | |
MYSQL_IN_USE: ${{ matrix.database == 'mariadb' }} | |
with: | |
arguments: spec -Dspec.test.client.host=candlepin | |
- name: Collect docker logs on failure | |
if: failure() | |
uses: jwalton/gh-docker-logs@2741064ab9d7af54b0b1ffb6076cf64c16f0220e | |
with: | |
dest: './logs-${{ matrix.database }}-${{ matrix.mode }}' | |
- name: Collect candlepin and Tomcat logs on failure | |
if: failure() | |
shell: bash | |
run: | | |
docker cp candlepin:/var/log/candlepin/ ./logs-${{ matrix.database }}-${{ matrix.mode }}/candlepin/ | |
docker cp candlepin:/opt/tomcat/logs/ ./logs-${{ matrix.database }}-${{ matrix.mode }}/tomcat/ | |
- name: Collect postgress logs on failure | |
if: failure() && matrix.database == 'postgres' | |
run: docker cp postgres:/var/log/postgresql/ ./logs-${{ matrix.database }}-${{ matrix.mode }}/postgresql/ | |
- name: Collect mariadb logs on failure | |
if: failure() && matrix.database == 'mariadb' | |
run: docker cp mariadb:/var/log/mysql/ ./logs-${{ matrix.database }}-${{ matrix.mode }}/mysql/ | |
- name: Tar logs | |
if: failure() | |
run: sudo tar cvzf ./logs-${{ matrix.database }}-${{ matrix.mode }}.tgz ./logs-${{ matrix.database }}-${{ matrix.mode }} | |
- name: Upload logs to GitHub | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logs-${{ matrix.database }}-${{ matrix.mode }}.tgz | |
path: ./logs-${{ matrix.database }}-${{ matrix.mode }}.tgz | |
- if: always() | |
name: Stop containers | |
shell: bash | |
run: docker compose -f ./.github/containers/${{ matrix.database }}.docker-compose.yml down |