diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a13c6d6..953b400 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,17 +15,48 @@ on: inventoros_ref: description: 'Inventoros branch, tag or SHA to test against' required: false + type: string + default: main + workflow_call: + inputs: + inventoros_ref: + description: 'Inventoros branch, tag or SHA to test against' + required: false + type: string + default: main + +permissions: + contents: read env: PLUGIN_SLUG: shopify # Pin to the lowest release the plugin supports (plugin.json "requires") # once the core tags it; main until then. - INVENTOROS_REF: ${{ github.event.inputs.inventoros_ref || 'main' }} + INVENTOROS_REF: ${{ inputs.inventoros_ref || 'main' }} jobs: + workflows: + name: Workflow validation + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + + - name: Validate GitHub Actions workflows + run: | + mkdir -p "$RUNNER_TEMP/actionlint" + curl --fail --location --retry 3 \ + https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz \ + --output "$RUNNER_TEMP/actionlint.tar.gz" + printf '%s %s\n' '8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8' "$RUNNER_TEMP/actionlint.tar.gz" | sha256sum --check --status + tar -xzf "$RUNNER_TEMP/actionlint.tar.gz" -C "$RUNNER_TEMP/actionlint" + "$RUNNER_TEMP/actionlint/actionlint" -color + ui: name: UI bundle - runs-on: ubuntu-latest + needs: workflows + runs-on: ubuntu-24.04 + timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -46,11 +77,13 @@ jobs: name: dist path: dist/ if-no-files-found: error + retention-days: 7 tests: name: tests (${{ matrix.database }}) needs: ui - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 30 strategy: fail-fast: false matrix: @@ -102,7 +135,7 @@ jobs: uses: actions/checkout@v4 with: repository: Inventoros/Inventoros - ref: ${{ matrix.core_ref || env.INVENTOROS_REF }} + ref: ${{ env.INVENTOROS_REF }} path: core - name: Setup PHP @@ -115,7 +148,7 @@ jobs: - name: Get Composer cache directory id: composer-cache working-directory: core - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - uses: actions/cache@v4 with: @@ -157,7 +190,8 @@ jobs: package: name: package + install from ZIP needs: tests - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + timeout-minutes: 15 steps: - name: Check out the plugin uses: actions/checkout@v4 @@ -173,7 +207,7 @@ jobs: uses: actions/checkout@v4 with: repository: Inventoros/Inventoros - ref: ${{ matrix.core_ref || env.INVENTOROS_REF }} + ref: ${{ env.INVENTOROS_REF }} path: core - name: Setup PHP @@ -195,7 +229,7 @@ jobs: - name: Build the ZIP id: zip working-directory: plugin - run: echo "path=$(php bin/package.php)" >> $GITHUB_OUTPUT + run: echo "path=$(php bin/package.php)" >> "$GITHUB_OUTPUT" - name: Install, activate, deactivate and delete the ZIP run: php plugin/bin/verify-package.php core "${{ steps.zip.outputs.path }}" "${{ env.PLUGIN_SLUG }}" @@ -204,3 +238,5 @@ jobs: with: name: plugin-zip path: plugin/build/ + if-no-files-found: error + retention-days: 7 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8959000..4a1a11d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,81 +1,63 @@ name: Release -# Push a tag vX.Y.Z (matching "version" in plugin.json) to publish a GitHub -# release with the installable ZIP and its sha256. The marketplace imports the -# ZIP and signs it with its own key: -# php artisan marketplace:import-release-asset --changelog="..." -# Paid plugins live in private repositories, whose release assets need a -# token to download: submit those through inventoros.com/developer instead. - +# A tag publishes the exact ZIP that passed the CI database matrix and the +# real install/activate/delete cycle. Verification has no publishing rights. on: push: tags: ['v*'] permissions: - contents: write + contents: read env: PLUGIN_SLUG: shopify - INVENTOROS_REF: main jobs: + verify: + name: Verify release + uses: ./.github/workflows/ci.yml + with: + inventoros_ref: main + release: - runs-on: ubuntu-latest + needs: verify + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: write steps: - uses: actions/checkout@v4 with: path: plugin - - name: Check the tag matches plugin.json - working-directory: plugin - run: | - version=$(php -r 'echo json_decode(file_get_contents("plugin.json"), true)["version"];') - if [ "v$version" != "${GITHUB_REF_NAME}" ]; then - echo "Tag ${GITHUB_REF_NAME} does not match plugin.json version $version" >&2 - exit 1 - fi - grep -q "## \[$version\]" CHANGELOG.md || { echo "CHANGELOG.md has no [$version] section" >&2; exit 1; } - - - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Build the runtime bundle - working-directory: plugin/ui - run: | - npm ci - npm run build - - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '8.4' - extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, sqlite3, dom, filter, gd, json, libxml, openssl, pcre, phar, tokenizer, zip, bcmath coverage: none - - name: Check out Inventoros - uses: actions/checkout@v4 - with: - repository: Inventoros/Inventoros - ref: ${{ env.INVENTOROS_REF }} - path: core - - - name: Install Inventoros with a real database - working-directory: core + - name: Check the tag matches plugin.json + working-directory: plugin run: | - composer install --no-interaction --prefer-dist --no-dev - cp .env.example .env - php artisan key:generate - touch database/database.sqlite - php artisan migrate --force + version=$(php -r 'echo json_decode(file_get_contents("plugin.json"), true, 512, JSON_THROW_ON_ERROR)["version"];') + if [ "v$version" != "$GITHUB_REF_NAME" ]; then + echo "Tag $GITHUB_REF_NAME does not match plugin.json version $version" >&2 + exit 1 + fi + grep -Fq "## [$version]" CHANGELOG.md || { echo "CHANGELOG.md has no [$version] section" >&2; exit 1; } - - name: Build the ZIP - id: zip - working-directory: plugin - run: echo "path=$(php bin/package.php)" >> $GITHUB_OUTPUT + - name: Download the verified ZIP + uses: actions/download-artifact@v4 + with: + name: plugin-zip + path: plugin/build - - name: Verify the ZIP installs and uninstalls cleanly - run: php plugin/bin/verify-package.php core "${{ steps.zip.outputs.path }}" "${{ env.PLUGIN_SLUG }}" + - name: Verify the release archive checksum + working-directory: plugin + run: | + version=$(php -r 'echo json_decode(file_get_contents("plugin.json"), true, 512, JSON_THROW_ON_ERROR)["version"];') + zip="build/${PLUGIN_SLUG}-${version}.zip" + printf '%s %s\n' "$(cat "${zip}.sha256")" "$zip" | sha256sum --check - - name: Publish the GitHub release working-directory: plugin @@ -83,9 +65,12 @@ jobs: GH_TOKEN: ${{ github.token }} run: | version=${GITHUB_REF_NAME#v} - notes=$(awk "/^## \\[$version\\]/{flag=1; next} /^## \\[/{flag=0} flag" CHANGELOG.md) + awk -v heading="## [$version]" ' + /^## \[/ { if (found) exit; if (index($0, heading) == 1) { found = 1; next } } + found + ' CHANGELOG.md > "$RUNNER_TEMP/release-notes.md" gh release create "$GITHUB_REF_NAME" \ "build/${PLUGIN_SLUG}-${version}.zip" \ "build/${PLUGIN_SLUG}-${version}.zip.sha256" \ - --title "$GITHUB_REF_NAME" \ - --notes "$notes" + --verify-tag --title "$GITHUB_REF_NAME" \ + --notes-file "$RUNNER_TEMP/release-notes.md" diff --git a/README.md b/README.md index 653eaee..c5976bf 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,14 @@ vendor/bin/phpunit -c plugins/shopify/phpunit.mysql.xml # MySQL README screenshots: `SCREENSHOTS=1 npx playwright test -c plugins/shopify/e2e/playwright.config.ts` against a served, seeded core (see the config file). +### CI and releases + +CI validates the workflow files, builds the runtime UI, runs the plugin tests on SQLite, PostgreSQL and MySQL, and checks the core plugin system. It then builds the ZIP and runs the real install, activation, deactivation, reactivation and deletion cycle. The manual CI action accepts an Inventoros branch, tag or SHA for compatibility checks. + +Pushing a `vX.Y.Z` tag runs that same verification pipeline before publishing. The tag must match `plugin.json` and have a changelog section. The release downloads the verified ZIP, checks its SHA-256 and publishes that artifact; it does not rebuild the archive. Only the publishing job has repository write access. CI artifacts expire after seven days; published release assets remain available. + +If a private-repository run fails with no steps and an annotation about account payments or a spending limit, GitHub has refused to allocate a runner. Restore the account's Actions billing or allowance before retrying; changing workflow code cannot clear that account restriction. + ## FAQ **Does Inventoros slow down when Shopify is slow or down?** No. Requests only queue work; Shopify outages show up as retries and failed items, and the connection pauses itself after repeated failures.