Skip to content

Cleanup

Cleanup #1178

Workflow file for this run

name: 🏗️🧪 Build and Test
on:
push:
branches:
- "main"
- "mw-*"
pull_request:
paths-ignore:
- 'docs/**'
- '**/*.md'
- '**/*.txt'
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Lint
run: ./lint.sh
build:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
component:
[
"wikibase",
"elasticsearch",
"wdqs",
"wdqs-frontend",
"wdqs-proxy",
"quickstatements",
]
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Build
shell: bash
run: ./build.sh --save-image ${{ matrix.component }}
- name: Archive Docker artifact
uses: actions/upload-artifact@v3
with:
name: DockerImages
path: artifacts/${{ matrix.component }}*.docker.tar.gz
if-no-files-found: error
- name: Scan Image
uses: ./.github/actions/scan-image
continue-on-error: true
with:
image_name: ${{ matrix.component }}
# TODO: remove extra step with https://phabricator.wikimedia.org/T347000
- name: Scan additional bundle Image for wikibase builds
if: matrix.component == 'wikibase'
uses: ./.github/actions/scan-image
continue-on-error: true
with:
image_name: "${{ matrix.component }}-bundle"
test:
strategy:
fail-fast: false
matrix:
suite:
[
repo,
fedprops,
repo_client,
quickstatements,
pingback,
confirm_edit,
elasticsearch,
base__repo,
base__repo_client,
base__pingback,
base__fedprops,
example
]
needs:
- build
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Get built Docker artifacts
uses: actions/download-artifact@v3
with:
name: DockerImages
path: artifacts/
- name: Test ${{ matrix.suite }}
run: ./test.sh ${{ matrix.suite }}
- name: Report Selenium
if: always()
run: |
cd .github/reporter
npm install
node report.js ${{ matrix.suite }}
- name: Show Logs
if: always()
continue-on-error: true
run: |
ls -lahr test/suites/${{ matrix.suite }}/results test/suites/${{ matrix.suite }}/results/*
tail -n +1 test/suites/${{ matrix.suite }}/results/*.log
- name: Archive Docker test artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: TestResults
path: test/suites/**/results
test_upgrade:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# TODO: can we get this from the environment to not have it hardcoded in the pipeline code?
version: [
# Latest 1.37
'WMDE9',
'WMDE9_BUNDLE',
# Latest 1.38
'WMDE12',
'WMDE12_BUNDLE',
# Latest 1.39
'WMDE13',
'WMDE13_BUNDLE'
]
needs:
- build
steps:
- uses: actions/checkout@v4
- name: Get built Docker artifacts
uses: actions/download-artifact@v3
with:
name: DockerImages
path: artifacts/
- name: Test upgrade from ${{ matrix.version }}
# This step should only take ~5 mins to complete, but sometimes seems to lock up and use the whole job timeout
# Set a specific lower timeout to allow us to retry sooner
timeout-minutes: 10
run: ./test.sh upgrade ${{ matrix.version }}
# TODO: DRY
- name: Archive Docker test artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: TestResults
path: test/suites/**/results
upload_ghcr:
runs-on: ubuntu-latest
timeout-minutes: 20
# we only upload builds to github container registry
# - from main branch builds
# - from release branch builds and
# - builds from PRs going to a release branch
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/mw-') || startsWith(github.base_ref, 'mw-')
needs:
- test
- test_upgrade
strategy:
fail-fast: false
matrix:
docker_image:
[
"wikibase/wikibase",
"wikibase/wikibase-bundle",
"wikibase/elasticsearch",
"wikibase/wdqs",
"wikibase/wdqs-frontend",
"wikibase/wdqs-proxy",
"wikibase/quickstatements",
]
steps:
- uses: actions/checkout@v4
- name: Get built Docker images
uses: actions/download-artifact@v3
with:
name: DockerImages
path: artifacts/
- name: Load docker images
shell: bash
run: |
for file in artifacts/*.docker.tar.gz; do
docker load -i "$file"
done
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push docker image to GHCR
shell: bash
run: |
set -x
# Get the docker tag name != latest of the image we are currently looking at. (The version string that is)
version_tag=$(docker image ls | grep -e '^${{ matrix.docker_image }} ' | grep -v latest | awk '{print $2}' | head -n 1)
# We need to retag the container for GHCR because the current tag is targetting docker hub.
# We will push two tags to GHCR, a version tag and a tag representing the current CI pipeline run id.
# Let's create "from" and "to" container URLs first.
from_url=${{ matrix.docker_image }}:"$version_tag"
to_url_version=ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_image }}:"$version_tag"
to_url_run_id=ghcr.io/${{ github.repository_owner }}/${{ matrix.docker_image }}:${{ github.run_id }}
# Retag and push
docker tag "$from_url" "$to_url_version"
docker tag "$from_url" "$to_url_run_id"
docker push "$to_url_version"
docker push "$to_url_run_id"