Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,27 @@
disable_search: true
files: coverage-feature.xml
flags: feature

e2e:
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 ./...
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",
})
}
27 changes: 12 additions & 15 deletions testdata/script/closed-wpackagist.txtar
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
env COMPOSER_NO_INTERACTION=1
env COMPOSER_CACHE_DIR=/dev/null

exec composer config --quiet repositories.wp-org-closed-plugin path $PWD
exec composer install --quiet

! exec composer audit
! exec composer audit --format=json

cmp stdout golden.out
cmp stderr golden.err

-- composer.json --
{
Expand All @@ -19,24 +15,25 @@ cmp stderr golden.err
},
"repositories": {
"wpackagist": {
"type":"composer",
"url":"https://wpackagist.org"
"type": "composer",
"url": "https://wpackagist.org"
}
},
"config": {
"allow-plugins": {
"composer/installers": true,
"typisttech/wp-org-closed-plugin": true
},
"audit": {
"abandoned": "fail"
}
}
}

-- golden.out --
+-------------------------+----------------------------------------------------------------------------------+
| Abandoned Package | Suggested Replacement |
+-------------------------+----------------------------------------------------------------------------------+
| wpackagist-plugin/moody | none |
+-------------------------+----------------------------------------------------------------------------------+
-- golden.err --
No security vulnerability advisories found.
Found 1 abandoned package:
{
"advisories": [],
"abandoned": {
"wpackagist-plugin/moody": null
}
}
Loading