CI #412
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 "`date`: Installing YAML::Syck, needed for Koha 20.11 and earlier" | |
docker exec koha-koha-1 apt-get install -y libyaml-syck-perl libemail-valid-perl libmojo-jwt-perl | |
while [ $? -ne 0 ]; do echo "INSTALL YAML::Syck" && docker exec koha-koha-1 apt-get install -y libyaml-syck-perl libemail-valid-perl; done | |
echo "SLEEPING 3 MINUTES" | |
sleep 60 | |
echo "1 MINUTE DONE" | |
sleep 60 | |
echo "2 MINUTES DONE" | |
sleep 60 | |
echo "3 MINUTES DONE" | |
echo "WAKING UP" | |
echo "DOCKER LOGS" | |
docker logs koha-koha-1 2>&1 | |
echo "/DOCKER LOGS" | |
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 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/CoverFlow.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 }} |