Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ updates:
directory: /
schedule:
interval: weekly
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ permissions:
jobs:
php:
uses: typisttech/.github/.github/workflows/audit-php.yml@v3

go:
uses: typisttech/.github/.github/workflows/audit-go.yml@v3
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ jobs:
php:
uses: typisttech/.github/.github/workflows/lint-php.yml@v3

go:
uses: typisttech/.github/.github/workflows/lint-go.yml@v3

wait-for-all-lint:
needs:
- php
- go
runs-on: ubuntu-latest
steps:
- run: exit 0
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,36 @@
disable_search: true
files: coverage-feature.xml
flags: feature

e2e:
name: e2e (PHP ${{ matrix.php-version }}, Composer ${{ matrix.composer-version }})
needs: php-matrix
strategy:
matrix:
php-version: ${{ fromJSON(needs.php-matrix.outputs.versions) }}
composer-version: ['2.6', '2.7', '2.8']
runs-on: ubuntu-latest
env:
GOFLAGS: '-mod=mod'
steps:
- uses: actions/checkout@v5

- uses: shivammathur/setup-php@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium test

Unpinned 3rd party Action 'Test' step
Uses Step
uses 'shivammathur/setup-php' with ref 'v2', not a pinned commit hash
with:
php-version: ${{ matrix.php-version }}
tools: composer:${{ matrix.composer-version }}
coverage: 'none'

- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'

- run: go test -count=1 ./...

wait-for-all-tests:
needs:
- pest
- e2e
runs-on: ubuntu-latest
steps:
- run: exit 0
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG composer=latest
ARG php=8

FROM composer:${composer} AS composer-bin

FROM php:${php}-cli-alpine

ENV PATH="/usr/local/go/bin:$PATH"
ENV GOROOT=/usr/local/go
ENV GOTOOLCHAIN=local
ENV GOFLAGS=-mod=mod

COPY --from=composer-bin --link /usr/bin/composer /usr/bin/composer
COPY --from=golang:1-alpine --link /usr/local/go /usr/local/go

COPY go.mod go.sum /tmp-app/
WORKDIR /tmp-app
RUN go mod download && rm -rf /tmp-app

WORKDIR /app

CMD ["go", "test", "./..."]
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export GOFLAGS=-mod=mod

combos := php-8-composer-latest \
php-8.4-composer-2.8 \
php-8.4-composer-2.7 \
php-8.4-composer-2.6

buildflags ?= --quiet

define GEN_RULE
build-php-$(1)-composer-$(2):
docker build $(buildflags) --build-arg php=$(1) --build-arg composer=$(2) --tag wp-org-closed-plugin:php-$(1)-composer-$(2) .

test-php-$(1)-composer-$(2): build-php-$(1)-composer-$(2)
docker run --volume $(shell pwd):/app --rm wp-org-closed-plugin:php-$(1)-composer-$(2) $(testcmd)
endef

$(foreach combo,$(combos), $(eval $(call GEN_RULE,$(word 2,$(subst -, ,$(combo))),$(word 4,$(subst -, ,$(combo))))))

test: $(foreach c,$(combos), test-$(c))

build-latest: build-php-8-composer-latest
test-latest: test-php-8-composer-latest

test-local:
go test ./...

update-scripts:
UPDATE_SCRIPTS=1 $(MAKE) test-local

clean:
@IMAGE_IDS="$(shell docker images -q wp-org-closed-plugin)"; \
if test -z "$${IMAGE_IDS}"; then \
echo "Skip: No wp-org-closed-plugin images found."; \
else \
docker rmi $${IMAGE_IDS}; \
fi
134 changes: 67 additions & 67 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
{
"name": "typisttech/wp-org-closed-plugin",
"description": "TODO",
"license": "MIT",
"type": "composer-plugin",
"keywords": [
"TODO"
],
"authors": [
{
"name": "Typist Tech",
"homepage": "https://typist.tech"
"name": "typisttech/wp-org-closed-plugin",
"description": "TODO",
"license": "MIT",
"type": "composer-plugin",
"keywords": [
"TODO"
],
"authors": [
{
"name": "Typist Tech",
"homepage": "https://typist.tech"
},
{
"name": "Tang Rufus",
"email": "[email protected]",
"homepage": "https://tangrufus.com",
"role": "Developer"
}
],
"homepage": "https://github.com/typisttech/wp-org-closed-plugin",
"support": {
"issues": "https://github.com/typisttech/wp-org-closed-plugin/issues",
"source": "https://github.com/typisttech/wp-org-closed-plugin",
"security": "https://github.com/typisttech/wp-org-closed-plugin/security"
},
{
"name": "Tang Rufus",
"email": "[email protected]",
"homepage": "https://tangrufus.com",
"role": "Developer"
}
],
"homepage": "https://github.com/typisttech/wp-org-closed-plugin",
"support": {
"issues": "https://github.com/typisttech/wp-org-closed-plugin/issues",
"source": "https://github.com/typisttech/wp-org-closed-plugin",
"security": "https://github.com/typisttech/wp-org-closed-plugin/security"
},
"require": {
"php": "^8.4",
"composer-plugin-api": "^2.6"
},
"require-dev": {
"composer/composer": "^2.8",
"pestphp/pest": "^4.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0"
},
"autoload": {
"psr-4": {
"TypistTech\\WpOrgClosedPlugin\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
"require": {
"php": "^8.4",
"composer-plugin-api": "^2.6"
},
"sort-packages": true
},
"extra": {
"class": "TypistTech\\WpOrgClosedPlugin\\Main",
"plugin-modifies-downloads": true,
"plugin-optional": true
},
"scripts": {
"lint": [
"@composer normalize --dry-run",
"pint --test",
"phpstan analyse"
],
"pest": "pest",
"pest:feature": "pest --group=feature",
"pest:unit": "pest --group=unit"
}
"require-dev": {
"composer/composer": "^2.8",
"pestphp/pest": "^4.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0"
},
"autoload": {
"psr-4": {
"TypistTech\\WpOrgClosedPlugin\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
},
"sort-packages": true
},
"extra": {
"class": "TypistTech\\WpOrgClosedPlugin\\Main",
"plugin-modifies-downloads": true,
"plugin-optional": true
},
"scripts": {
"lint": [
"@composer normalize --dry-run",
"pint --test",
"phpstan analyse"
],
"pest": "pest",
"pest:feature": "pest --group=feature",
"pest:unit": "pest --group=unit"
}
}
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/typisttech/wp-org-closed-plugin

go 1.25.3

require github.com/rogpeppe/go-internal v1.14.1

require (
golang.org/x/sys v0.26.0 // indirect
golang.org/x/tools v0.26.0 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
24 changes: 24 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main_test

import (
"os"
"testing"

"github.com/rogpeppe/go-internal/testscript"
)

func Test(t *testing.T) {
testscript.Run(t, testscript.Params{
Dir: "testdata/script",
Setup: func(env *testscript.Env) error {
wd, err := os.Getwd()
if err != nil {
return err
}
env.Setenv("PWD", wd)
env.Setenv("COMPOSER_CACHE_DIR", "/dev/null")
return nil
},
UpdateScripts: os.Getenv("UPDATE_SCRIPTS") == "1",
})
}
Loading
Loading