This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/.github/workflows/tests.yml

173 lines
4.7 KiB
YAML
Raw Normal View History

2021-12-13 01:04:47 +00:00
name: Tests
2019-11-21 16:59:07 +00:00
2020-03-20 16:59:11 +00:00
on:
push:
branches:
- main
- master
2020-03-20 16:59:11 +00:00
pull_request:
schedule:
- cron: '0 2 * * 0' # Weekly on Sundays at 02:00
2019-11-21 16:59:07 +00:00
jobs:
2020-11-15 13:29:06 +00:00
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
2024-02-12 13:51:11 +00:00
uses: actions/checkout@v4
2021-03-15 00:25:30 +00:00
- name: Set Up Cache
2024-02-12 13:53:25 +00:00
uses: actions/cache@v4
2021-03-15 00:25:30 +00:00
with:
path: |
vendor
key: php-cs-fixer-${{ hashFiles('composer.lock') }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install PHP dependencies
run: composer install --prefer-dist --no-progress
2021-03-15 00:25:30 +00:00
- name: Set up PHP
uses: shivammathur/setup-php@master
with:
2023-12-17 22:43:06 +00:00
php-version: 8.3
2022-10-27 16:24:35 +00:00
- name: Format
2024-02-27 00:51:16 +00:00
run: composer format && git diff --exit-code
2020-11-15 13:29:06 +00:00
2023-02-03 16:44:16 +00:00
static:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
2024-02-12 13:51:11 +00:00
uses: actions/checkout@v4
2023-02-03 16:44:16 +00:00
with:
fetch-depth: 2
2023-02-03 16:49:25 +00:00
- name: Set Up Cache
2024-02-12 13:53:25 +00:00
uses: actions/cache@v4
2023-02-03 16:49:25 +00:00
with:
path: |
vendor
key: phpstan-${{ hashFiles('composer.lock') }}
- name: Install PHP dependencies
run: composer install --prefer-dist --no-progress
2023-02-03 16:44:16 +00:00
- name: PHPStan
2024-02-27 00:51:16 +00:00
run: composer stan
2023-02-03 16:44:16 +00:00
upgrade:
name: Upgrade from 2.9 ${{ matrix.database }}
strategy:
matrix:
php: ['8.3']
database: ['pgsql', 'mysql', 'sqlite']
runs-on: ubuntu-latest
steps:
2024-01-06 21:52:21 +00:00
- name: Checkout current
2024-02-12 13:51:11 +00:00
uses: actions/checkout@v4
with:
fetch-depth: 0
2024-01-06 21:52:21 +00:00
- name: Travel to past
# is there a way to programatically get "the most recent
# tagged minor version of the previous major version"?
run: git checkout branch-2.9
- name: Set Up Cache
2024-02-12 13:53:25 +00:00
uses: actions/cache@v4
with:
path: |
vendor
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
- name: Set up PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
- name: Set up database
run: ./tests/setup-db.sh "${{ matrix.database }}"
- name: Install PHP dependencies
run: composer install --no-progress
2024-01-15 21:16:09 +00:00
- name: Install old version
2024-01-15 21:21:27 +00:00
run: |
php index.php
2024-01-15 21:39:17 +00:00
cat data/config/shimmie.conf.php
- name: Check old version works
2024-01-15 23:07:11 +00:00
run: |
php index.php get-page / > old.out
grep -q 'Welcome to Shimmie 2.9' old.out || cat old.out
rm -f old.out
- name: Upgrade
run: |
2024-01-05 16:39:20 +00:00
git checkout ${{ github.sha }}
composer install --no-progress
2024-01-15 23:08:56 +00:00
php index.php db-upgrade
- name: Check new version works
2024-01-15 23:07:11 +00:00
run: |
php index.php page:get / > new.out
grep -q 'Welcome to Shimmie 2.10' new.out || cat new.out
rm -f new.out
2020-03-19 13:44:56 +00:00
test:
2019-11-21 16:59:07 +00:00
name: PHP ${{ matrix.php }} / DB ${{ matrix.database }}
strategy:
2019-11-22 23:03:34 +00:00
fail-fast: false
2019-11-21 16:59:07 +00:00
matrix:
2023-12-14 17:10:09 +00:00
php: ['8.1', '8.2', '8.3']
2019-11-21 17:28:02 +00:00
database: ['pgsql', 'mysql', 'sqlite']
runs-on: ubuntu-latest
2019-11-21 16:59:07 +00:00
steps:
- name: Checkout
2024-02-12 13:51:11 +00:00
uses: actions/checkout@v4
2022-10-28 16:38:53 +00:00
with:
fetch-depth: 2
2020-10-24 21:55:04 +00:00
- name: Set Up Cache
2024-02-12 13:53:25 +00:00
uses: actions/cache@v4
2020-10-24 21:55:04 +00:00
with:
path: |
vendor
2020-10-27 01:50:56 +00:00
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
2019-11-21 16:59:07 +00:00
- name: Set up PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
coverage: pcov
2020-01-26 16:40:52 +00:00
extensions: mbstring
ini-file: development
2019-11-21 17:42:31 +00:00
- name: Set up database
run: ./tests/setup-db.sh "${{ matrix.database }}"
2019-11-21 17:42:31 +00:00
- name: Check versions
run: php -v && composer -V
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install PHP dependencies
run: composer install --no-progress
2019-11-21 16:59:07 +00:00
- name: Run test suite
2024-02-27 00:51:16 +00:00
run: composer test
2024-04-13 22:30:41 +00:00
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- format
- static
- upgrade
- test
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/branch-2')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set build vars
id: get-vars
run: |
echo "BUILD_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
echo "BUILD_HASH=$GITHUB_SHA" >> $GITHUB_ENV
./.github/get-tags.py | tee -a $GITHUB_OUTPUT
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@main
with:
name: shish2k/shimmie2
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
cache: ${{ github.event_name != 'schedule' }}
buildoptions: "--build-arg RUN_TESTS=false"
buildargs: BUILD_TIME,BUILD_HASH
tags: "${{ steps.get-vars.outputs.tags }}"