From 9a37203a7a809fbc7eff77bbe3c533529131cdc8 Mon Sep 17 00:00:00 2001 From: Bad Manners Date: Thu, 5 Sep 2024 12:39:29 -0300 Subject: [PATCH] Use Forgejo workflows for building --- .forgejo/workflows/ci.yml | 24 +++ .github/CONTRIBUTING.md | 38 ----- .github/ISSUE_TEMPLATE/bug_report.md | 28 ---- .github/ISSUE_TEMPLATE/feature_request.md | 17 --- .github/get-tags.py | 20 --- .github/workflows/main.yml | 26 ---- .github/workflows/release.yml | 41 ------ .github/workflows/tests.yml | 171 ---------------------- 8 files changed, 24 insertions(+), 341 deletions(-) create mode 100644 .forgejo/workflows/ci.yml delete mode 100644 .github/CONTRIBUTING.md delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100755 .github/get-tags.py delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 00000000..5a233252 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -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 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index 3d223ecf..00000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -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 $cakes -- a mapping like ["sponge" => new Cake()] - * @return array -- a list like [new Ingredient("flour"), new Ingredient("egg")] - */ -function get_ingredients(array $cakes, string $cake_name): array { - return $cakes[$cake_name]->ingredients; -} -``` diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 9b542a1d..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -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:///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. - diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 066b2d92..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -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. diff --git a/.github/get-tags.py b/.github/get-tags.py deleted file mode 100755 index a8ded364..00000000 --- a/.github/get-tags.py +++ /dev/null @@ -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) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 28b1cd44..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 6e8868d8..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 02279889..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -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 }}"