Skip to content

Commit

Permalink
Merge branch 'main' into permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
shish authored Sep 7, 2024
2 parents 38b16c1 + 0e47a5e commit 5c1d7ed
Show file tree
Hide file tree
Showing 301 changed files with 4,683 additions and 2,872 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},

"updateContentCommand": "composer install && cp ./.devcontainer/bash_history /root/.bash_history",
"postCreateCommand": "./.docker/entrypoint.sh php ./.docker/run.php",
"postStartCommand": "./.docker/entrypoint.sh php ./.docker/run.php",
"containerEnv": {
"UID": "2000",
"GID": "2000",
Expand Down
9 changes: 6 additions & 3 deletions .github/get-tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
describe = check_output(["git", "describe", "--tags"], text=True).strip()
tag = describe.split("-")[0][1:]
a, b, c = tag.split(".")
docker_username = sys.argv[1]
docker_image = sys.argv[2] if len(sys.argv) > 2 else "shimmie2"
image_name = f"{docker_username}/{docker_image}"

if branch == "main":
print("tags=latest")
print(f"tags={image_name}:latest")
elif branch.startswith("branch-2."):
if "-" in describe:
print(f"tags={a},{a}.{b}")
print(f"tags={image_name}:{a},{image_name}:{a}.{b}")
else:
print(f"tags={a},{a}.{b},{a}.{b}.{c}")
print(f"tags={image_name}:{a},{image_name}:{a}.{b},{image_name}:{a}.{b}.{c}")
else:
print("Only run from main or branch-2.X")
sys.exit(1)
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
merge-master-to-main:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set Git config
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
45 changes: 26 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
format:
name: Format
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -29,16 +29,12 @@ jobs:
run: composer validate
- name: Install PHP dependencies
run: composer install --prefer-dist --no-progress
- name: Set up PHP
uses: shivammathur/setup-php@master
with:
php-version: 8.3
- name: Format
run: composer format && git diff --exit-code

static:
name: Static Analysis
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -61,7 +57,7 @@ jobs:
matrix:
php: ['8.3']
database: ['pgsql', 'mysql', 'sqlite']
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout current
uses: actions/checkout@v4
Expand All @@ -78,7 +74,7 @@ jobs:
vendor
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
- name: Set up PHP
uses: shivammathur/setup-php@master
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Set up database
Expand Down Expand Up @@ -110,9 +106,9 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
php: ['8.2', '8.3']
database: ['pgsql', 'mysql', 'sqlite']
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -125,7 +121,7 @@ jobs:
vendor
key: vendor-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
- name: Set up PHP
uses: shivammathur/setup-php@master
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
Expand All @@ -144,7 +140,7 @@ jobs:

publish:
name: Publish
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs:
- format
- static
Expand All @@ -162,14 +158,25 @@ jobs:
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
./.github/get-tags.py ${{ secrets.DOCKER_USERNAME }} ${{ secrets.DOCKER_IMAGE }} | tee -a $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker registry
uses: docker/login-action@v3
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
- name: Build and push to registry
uses: docker/build-push-action@v6
with:
push: true
platforms: |
linux/amd64
linux/arm64
build-args: |
BUILD_TIME=${{ env.BUILD_TIME }}
BUILD_HASH=${{ env.BUILD_HASH }}
no-cache: ${{ github.event_name == 'schedule' }}
tags: "${{ steps.get-vars.outputs.tags }}"
14 changes: 8 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
;

$_phpcs_config = new PhpCsFixer\Config();
return $_phpcs_config->setRules([
'@PSR12' => true,
//'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($_phpcs_finder)
return $_phpcs_config
->setRules([
'@PSR12' => true,
//'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($_phpcs_finder)
->setCacheFile("data/php-cs-fixer.cache")
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
;
16 changes: 1 addition & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ARG PHP_VERSION=8.2
# base
# ├── dev-tools
# │ ├── build
# │ │ └── tests
# │ └── devcontainer
# └── run (copies built artifacts out of build)

Expand All @@ -22,7 +21,7 @@ RUN apt update && \
php${PHP_VERSION}-gd php${PHP_VERSION}-zip php${PHP_VERSION}-xml php${PHP_VERSION}-mbstring php${PHP_VERSION}-curl \
php${PHP_VERSION}-pgsql php${PHP_VERSION}-mysql php${PHP_VERSION}-sqlite3 \
php${PHP_VERSION}-memcached \
curl imagemagick zip unzip unit unit-php && \
curl rsync imagemagick zip unzip unit unit-php && \
rm -rf /var/lib/apt/lists/*

# Install dev packages
Expand All @@ -43,19 +42,6 @@ WORKDIR /app
RUN composer install --no-dev --no-progress
COPY . /app/

# Tests in their own image.
# Re-run composer install to get dev dependencies
FROM build AS tests
RUN composer install --no-progress
COPY . /app/
ARG RUN_TESTS=true
RUN [ $RUN_TESTS = false ] || (\
echo '=== Installing ===' && mkdir -p data/config && INSTALL_DSN="sqlite:data/shimmie.sqlite" php index.php && \
echo '=== Smoke Test ===' && php index.php get-page /post/list && \
echo '=== Unit Tests ===' && ./vendor/bin/phpunit --configuration tests/phpunit.xml && \
echo '=== Coverage ===' && ./vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text && \
echo '=== Cleaning ===' && rm -rf data)

# Devcontainer target
# Contains all of the build and debug tools, but no code, since
# that's mounted from the host
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

"config": {
"platform": {
"php": "8.1.0"
"php": "8.2.0"
}
},

Expand All @@ -31,11 +31,10 @@
],

"require" : {
"php" : "^8.1",
"php" : "^8.2",
"ext-pdo": "*",
"ext-json": "*",
"ext-fileinfo": "*",
"flexihash/flexihash": "^2.0",
"ifixit/php-akismet": "^1.0",
"google/recaptcha": "^1.1",
"shish/eventtracer-php": "^2.0",
Expand All @@ -57,9 +56,9 @@
},

"require-dev" : {
"phpunit/phpunit" : "10.5.3",
"friendsofphp/php-cs-fixer" : "3.41.1",
"phpstan/phpstan": "1.10.50",
"phpunit/phpunit" : "^11.0",
"friendsofphp/php-cs-fixer" : "^3.64",
"phpstan/phpstan": "^1.12",
"thecodingmachine/phpstan-safe-rule": "^1.2"
},
"suggest": {
Expand Down
Loading

0 comments on commit 5c1d7ed

Please sign in to comment.