[setup] 0 == null, but 0 !== null... #3698
This file contains hidden or 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: 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') }} | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.4 | |
| - 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-ci | |
| 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') }} | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.4 | |
| - name: Install PHP dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: PHPStan | |
| run: composer analyse-ci | |
| upgrade: | |
| name: Upgrade from 2.9 ${{ matrix.database }} | |
| strategy: | |
| matrix: | |
| php: ["8.4"] | |
| database: ["pgsql", "mysql", "sqlite"] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout current | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up database | |
| run: ./.github/setup-db.sh "${{ matrix.database }}" | |
| - 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: 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.12' new.out || (cat new.out && false) | |
| test: | |
| name: PHP ${{ matrix.php }} / DB ${{ matrix.database }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ["8.4", "8.5"] | |
| 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: ./.github/setup-db.sh "${{ matrix.database }}" | |
| - name: Check versions | |
| run: php -v && composer -V | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate | |
| - uses: mfinelli/setup-imagemagick@v7 | |
| - name: Install PHP dependencies | |
| run: composer install --no-progress | |
| - name: Run test suite | |
| run: composer test | |
| build: | |
| name: Build ${{ matrix.arch }} | |
| runs-on: ${{ matrix.os }} | |
| needs: | |
| - format | |
| - static | |
| - upgrade | |
| - test | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/branch-2') || startsWith(github.ref, 'refs/tags/v2') | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| arch: amd64 | |
| - os: ubuntu-24.04-arm | |
| arch: arm64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # buildx is needed for multi-architecture builds | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Figure out some variables to get baked into the image | |
| - 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 | |
| # build and push an anonymous image | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ matrix.platform }} | |
| tags: ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_IMAGE }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| build-args: | | |
| BUILD_TIME=${{ env.BUILD_TIME }} | |
| BUILD_HASH=${{ env.BUILD_HASH }} | |
| # record the image's ID in /tmp/digests/<image_id> | |
| - name: Export digest | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
| # upload the contents of /tmp/digests | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ matrix.arch }} | |
| path: ${{ runner.temp }}/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - build | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/branch-2') | |
| steps: | |
| # full checkout with tags so that get-tags.py can get the version number | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-tags: true | |
| fetch-depth: 0 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # get all files in /tmp/digests | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| # buildx is needed to create manifest lists | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # create a manifest based on /tmp/digests/* | |
| # the result of this command should look like | |
| # docker buildx imagetools create \ | |
| # -t shish2k/shimmie2:2.5.1 -t shish2k/shimmie2:2.5 -t shish2k/shimmie2:2 \ | |
| # shish2k/shimmie2@sha256:<amd64 digest> shish2k/shimmie2@sha256:<arm64 digest> | |
| - name: Create manifest list and push | |
| run: | | |
| docker buildx imagetools create \ | |
| $(printf -- "-t ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_IMAGE }}:%s " $(./.github/get-tags.py)) \ | |
| $(printf -- '${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_IMAGE }}@sha256:%s ' $(ls -1 ${{ runner.temp }}/digests)) |