This commit is contained in:
parent
3981ea188d
commit
9a37203a7a
8 changed files with 24 additions and 341 deletions
24
.forgejo/workflows/ci.yml
Normal file
24
.forgejo/workflows/ci.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to Forgejo Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.badmanners.xyz
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ github.token }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: git.badmanners.xyz/${{ github.repository }}:latest
|
38
.github/CONTRIBUTING.md
vendored
38
.github/CONTRIBUTING.md
vendored
|
@ -1,38 +0,0 @@
|
||||||
Vibes:
|
|
||||||
======
|
|
||||||
Generally-useful extensions are great, custom extensions and themes just for one specific DIY site
|
|
||||||
are welcome too. I (Shish) will probably only actively maintain and add features to the extensions
|
|
||||||
which I personally use, but if you submit some code of your own I will try to keep it updated and
|
|
||||||
compatible with any API changes that come along. If your code comes with unit tests, this type of
|
|
||||||
maintenance is much more likely to be successful :)
|
|
||||||
|
|
||||||
Testing:
|
|
||||||
========
|
|
||||||
Github Actions will be running three sets of automated tests, all of which you can run for yourself:
|
|
||||||
|
|
||||||
- `composer format` - keeping a single style for the whole project
|
|
||||||
- `composer test` - unit testing
|
|
||||||
- `composer stan` - type checking
|
|
||||||
|
|
||||||
The `main` branch is locked down so it can't accept pull requests that don't pass these
|
|
||||||
|
|
||||||
Testing FAQs:
|
|
||||||
=============
|
|
||||||
|
|
||||||
## What the heck is "Method XX::YY() return type has no value type specified in iterable type array."?
|
|
||||||
|
|
||||||
PHP arrays are very loosely defined - they can be lists or maps, with integer or string
|
|
||||||
(or non-continuous integer) keys, with any type of object (or multiple types of object).
|
|
||||||
This isn't great for type safety, so PHPStan is a bit stricter, and requires you to
|
|
||||||
specify what type of array it is and what it contains. You can do this with PHPdoc comments,
|
|
||||||
like:
|
|
||||||
|
|
||||||
```php
|
|
||||||
/**
|
|
||||||
* @param array<string, Cake> $cakes -- a mapping like ["sponge" => new Cake()]
|
|
||||||
* @return array<Ingredient> -- a list like [new Ingredient("flour"), new Ingredient("egg")]
|
|
||||||
*/
|
|
||||||
function get_ingredients(array $cakes, string $cake_name): array {
|
|
||||||
return $cakes[$cake_name]->ingredients;
|
|
||||||
}
|
|
||||||
```
|
|
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -1,28 +0,0 @@
|
||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Server Software**
|
|
||||||
(You can get all these stats from `http://<your site>/system_info`)
|
|
||||||
|
|
||||||
- Shimmie version:
|
|
||||||
- Database: [mysql, postgres, ...]
|
|
||||||
- Web server: [apache, nginx, ...]
|
|
||||||
|
|
||||||
**Client Software (please complete the following information)**
|
|
||||||
- Device: [e.g. iphone, windows desktop]
|
|
||||||
- Browser: [e.g. chrome, safari]
|
|
||||||
|
|
||||||
**What steps trigger this bug**
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
|
|
||||||
**What did you expect to happen?**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**What actually happened?**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
17
.github/ISSUE_TEMPLATE/feature_request.md
vendored
17
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
20
.github/get-tags.py
vendored
20
.github/get-tags.py
vendored
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from subprocess import check_output
|
|
||||||
import sys
|
|
||||||
|
|
||||||
branch = check_output(["git", "branch", "--show-current"], text=True).strip()
|
|
||||||
describe = check_output(["git", "describe", "--tags"], text=True).strip()
|
|
||||||
tag = describe.split("-")[0][1:]
|
|
||||||
a, b, c = tag.split(".")
|
|
||||||
|
|
||||||
if branch == "main":
|
|
||||||
print("tags=latest")
|
|
||||||
elif branch.startswith("branch-2."):
|
|
||||||
if "-" in describe:
|
|
||||||
print(f"tags={a},{a}.{b}")
|
|
||||||
else:
|
|
||||||
print(f"tags={a},{a}.{b},{a}.{b}.{c}")
|
|
||||||
else:
|
|
||||||
print("Only run from main or branch-2.X")
|
|
||||||
sys.exit(1)
|
|
26
.github/workflows/main.yml
vendored
26
.github/workflows/main.yml
vendored
|
@ -1,26 +0,0 @@
|
||||||
name: Master to Main
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: Tests
|
|
||||||
branches: master
|
|
||||||
types: completed
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
merge-master-to-main:
|
|
||||||
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Set Git config
|
|
||||||
run: |
|
|
||||||
git config --local user.email "actions@github.com"
|
|
||||||
git config --local user.name "Github Actions"
|
|
||||||
- name: Merge master back to dev
|
|
||||||
run: |
|
|
||||||
git fetch --unshallow
|
|
||||||
git checkout main
|
|
||||||
git pull
|
|
||||||
git merge --ff origin/master -m "Auto-merge master to main"
|
|
||||||
git push
|
|
41
.github/workflows/release.yml
vendored
41
.github/workflows/release.yml
vendored
|
@ -1,41 +0,0 @@
|
||||||
name: Create Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Create Release
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Get version from tag
|
|
||||||
id: get_version
|
|
||||||
run: echo VERSION=${GITHUB_REF/refs\/tags\/v/} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Check and set sys_config
|
|
||||||
run: |
|
|
||||||
grep ${{ steps.get_version.outputs.VERSION }} core/sys_config.php
|
|
||||||
echo "_d('BUILD_TIME', '$(date +'%Y-%m-%dT%H:%M:%S')');" >> core/sys_config.php
|
|
||||||
echo "_d('BUILD_HASH', '$GITHUB_SHA');" >> core/sys_config.php
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
composer install --no-dev --no-progress
|
|
||||||
cd ..
|
|
||||||
tar cvzf shimmie2-${{ steps.get_version.outputs.VERSION }}.tgz shimmie2
|
|
||||||
zip -r shimmie2-${{ steps.get_version.outputs.VERSION }}.zip shimmie2
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
name: Shimmie ${{ steps.get_version.outputs.VERSION }}
|
|
||||||
body: Automated release from tags
|
|
||||||
files: |
|
|
||||||
../shimmie2-${{ steps.get_version.outputs.VERSION }}.zip
|
|
||||||
../shimmie2-${{ steps.get_version.outputs.VERSION }}.tgz
|
|
171
.github/workflows/tests.yml
vendored
171
.github/workflows/tests.yml
vendored
|
@ -1,171 +0,0 @@
|
||||||
name: Tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- master
|
|
||||||
- branch-2.*
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
pull_request:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 2 * * 0' # Weekly on Sundays at 02:00
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
format:
|
|
||||||
name: Format
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Set Up Cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
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
|
|
||||||
- name: Format
|
|
||||||
run: composer format && git diff --exit-code
|
|
||||||
|
|
||||||
static:
|
|
||||||
name: Static Analysis
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 2
|
|
||||||
- name: Set Up Cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
vendor
|
|
||||||
key: phpstan-${{ hashFiles('composer.lock') }}
|
|
||||||
- name: Install PHP dependencies
|
|
||||||
run: composer install --prefer-dist --no-progress
|
|
||||||
- name: PHPStan
|
|
||||||
run: composer stan
|
|
||||||
|
|
||||||
upgrade:
|
|
||||||
name: Upgrade from 2.9 ${{ matrix.database }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
php: ['8.3']
|
|
||||||
database: ['pgsql', 'mysql', 'sqlite']
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout current
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- 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
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
vendor
|
|
||||||
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
|
|
||||||
- name: Set up PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
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
|
|
||||||
- name: Install old version
|
|
||||||
run: |
|
|
||||||
php index.php
|
|
||||||
cat data/config/shimmie.conf.php
|
|
||||||
- name: Check old version works
|
|
||||||
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: |
|
|
||||||
git checkout ${{ github.sha }}
|
|
||||||
composer install --no-progress
|
|
||||||
php index.php db-upgrade
|
|
||||||
- name: Check new version works
|
|
||||||
run: |
|
|
||||||
php index.php page:get / > new.out
|
|
||||||
grep -q 'Welcome to Shimmie 2.10' new.out || cat new.out
|
|
||||||
rm -f new.out
|
|
||||||
|
|
||||||
test:
|
|
||||||
name: PHP ${{ matrix.php }} / DB ${{ matrix.database }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
php: ['8.2', '8.3']
|
|
||||||
database: ['pgsql', 'mysql', 'sqlite']
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 2
|
|
||||||
- name: Set Up Cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
vendor
|
|
||||||
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
|
|
||||||
- name: Set up PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php }}
|
|
||||||
coverage: pcov
|
|
||||||
extensions: mbstring
|
|
||||||
ini-file: development
|
|
||||||
- name: Set up database
|
|
||||||
run: ./tests/setup-db.sh "${{ matrix.database }}"
|
|
||||||
- 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
|
|
||||||
- name: Run test suite
|
|
||||||
run: composer test
|
|
||||||
|
|
||||||
publish:
|
|
||||||
name: Publish
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
needs:
|
|
||||||
- format
|
|
||||||
- static
|
|
||||||
- upgrade
|
|
||||||
- test
|
|
||||||
if: github.ref == 'refs/heads/main' || 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 }}"
|
|
Reference in a new issue