CI #795
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: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*.*.*' | |
schedule: | |
- cron: "0 6 * * *" | |
jobs: | |
unit_tests: | |
name: Run unit tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
koha-version: [main, stable, oldstable] | |
steps: | |
- name: Is a tag? | |
run: | | |
echo "${{ startsWith(github.ref, 'refs/tags/v') }}" | |
- name: GitHub Ref 1 | |
run: | | |
echo "${GITHUB_REF##*/}" | |
- name: GitHub Ref 2 | |
run: | | |
echo "${{ github.event.ref }}" | |
- name: GitHub Ref 3 | |
run: | | |
echo "${{ github.ref }}" | |
- name: Dump env | |
run: env | sort | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v1 | |
- name: Get Koha Version Branch Name | |
id: koha-version | |
uses: "bywatersolutions/github-action-koha-get-version-by-label@master" | |
with: | |
version-label: "${{ matrix.koha-version }}" | |
- name: Check out Koha | |
run: | | |
cd .. | |
git clone --branch ${{ steps.koha-version.outputs.current-branch-name }} --single-branch --depth 1 https://github.com/Koha-Community/Koha.git kohaclone | |
- name: Export additional variables needed by koha-testing-docker | |
run: | | |
cd .. | |
pwd | |
ls -alh | |
IFS='/' read -r -a parts <<< "$GITHUB_REPOSITORY" | |
export GITHUB_REPO="${parts[1]}" | |
export ROOT_DIR="$(pwd)" | |
export LOCAL_USER_ID="$(id -u)" # Needed for koha-testing-docker | |
export SYNC_REPO="$ROOT_DIR/kohaclone" | |
export KOHA_INTRANET_URL="http://127.0.0.1:8081" | |
export KOHA_MARC_FLAVOUR="marc21" | |
echo "GITHUB_REPO=$GITHUB_REPO" >> $GITHUB_ENV | |
echo "ROOT_DIR=$ROOT_DIR" >> $GITHUB_ENV | |
echo "LOCAL_USER_ID=$LOCAL_USER_ID" >> $GITHUB_ENV | |
echo "SYNC_REPO=$SYNC_REPO" >> $GITHUB_ENV | |
echo "KOHA_INTRANET_URL=$KOHA_INTRANET_URL" >> $GITHUB_ENV | |
echo "KOHA_MARC_FLAVOUR=$KOHA_MARC_FLAVOUR" >> $GITHUB_ENV | |
echo "RUN_TESTS_AND_EXIT=no" >> $GITHUB_ENV | |
echo "KOHA_IMAGE=main" >> $GITHUB_ENV | |
echo "GITHUB REPO: $GITHUB_REPO" | |
echo "ROOT DIR: $ROOT_DIR" | |
echo "SYNC_REPO: $SYNC_REPO" | |
ls -alh $SYNC_REPO | |
- name: Set up koha-testing-docker | |
run: | | |
sudo sysctl -w vm.max_map_count=262144 | |
wget -O docker-compose.yml https://gitlab.com/koha-community/koha-testing-docker/raw/main/docker-compose.yml | |
mkdir -p env | |
wget -O env/defaults.env https://gitlab.com/koha-community/koha-testing-docker/raw/main/env/defaults.env | |
cp env/defaults.env .env | |
docker compose pull | |
# - name: Setup Debug Session | |
# uses: csexton/debugger-action@master | |
- name: Run tests | |
run: | | |
pwd | |
ls -alh | |
docker compose -f docker-compose.yml -p koha up --detach | |
cd .. | |
pwd | |
ls -alh | |
echo "KTD: Waiting for KTD to warm up" | |
for i in $(seq 1 200); do | |
if docker exec koha-koha-1 bash -c '[ -e /ktd_ready ]'; then | |
printf "\n" | |
break | |
elif [ "$i" != "200" ]; then | |
printf "\rAttempt $i of 200" | |
sleep 1 | |
else | |
printf "KTD: Timeout waiting for KTD to be ready (ERROR)" | |
exit 1 | |
fi | |
done | |
echo "KTD: ready!" | |
docker cp $GITHUB_REPO/. koha-koha-1:/var/lib/koha/kohadev/plugins | |
docker exec koha-koha-1 bash -c 'prove /var/lib/koha/kohadev/plugins/t' | |
- name: Post test cleanup | |
run: | | |
docker compose down | |
docker rm -f $(docker ps -a -f "name=koha-" -q) | |
docker volume prune -f | |
docker image prune -f | |
rm docker-compose.yml | |
rm -rf env .env | |
release: | |
name: Build & Release | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: unit_tests | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Parse out and store the GitHub repository name | |
id: myvars | |
run: | | |
IFS='/' read -r -a parts <<< "$GITHUB_REPOSITORY" | |
GITHUB_REPO="${parts[1]}" | |
echo ::set-output name=github_repo::$GITHUB_REPO | |
echo "GITHUB REPO: $GITHUB_REPO" | |
TAG_VERSION="${GITHUB_REF##*/}" | |
echo "TAG VERSION: $TAG_VERSION" | |
TAG_VERSION="${TAG_VERSION:1}" | |
echo "TAG VERSION 2: $TAG_VERSION" | |
echo ::set-output name=tag_version::$TAG_VERSION | |
- name: Get Koha Version Branch Name | |
id: koha-version-oldstable | |
uses: "bywatersolutions/github-action-koha-get-version-by-label@master" | |
with: | |
version-label: "oldstable" | |
- name: Print minimum version | |
run: | | |
echo "Current oldstable version: ${{ steps.koha-version-oldstable.outputs.version-major-minor }}" | |
- name: Dump myvars outputs | |
env: | |
GITHUB_CONTEXT: ${{ toJson(steps.myvars.outputs) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Build Koha Plugin kpz artifact | |
id: kpz | |
uses: "bywatersolutions/github-action-koha-plugin-create-kpz@master" | |
with: | |
release-version: ${{ steps.myvars.outputs.tag_version }} | |
release-name: ${{ steps.myvars.outputs.github_repo }} | |
minimum-version: ${{ steps.koha-version-oldstable.outputs.version-major-minor }} | |
plugin-module: "Koha/Plugin/Com/ByWaterSolutions/CurbsidePickup.pm" | |
- name: See if kpz was created | |
run: | | |
echo "FILENAME: ${{ steps.kpz.outputs.filename }}" | |
ls -alh | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
${{ steps.kpz.outputs.filename }} | |
CHANGELOG.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
keepalive: | |
name: Keep Alive | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check age and push commit if needed | |
run: | | |
LAST_COMMIT=$( git --no-pager log -1 --format=%ct ) | |
NOW=$(date +%s) | |
DIFF=$(($NOW-$LAST_COMMIT)) | |
DAYS=$(($DIFF/86400)) | |
git config --global user.email [email protected] | |
git config --global user.name "Kyle M Hall" | |
git commit --allow-empty -m "Automated commit from keep alive workflow" | |
if [ "$DAYS" -gt "50" ]; then git push; fi |