Skip to content

Commit ba0e34a

Browse files
authored
Merge pull request #64 from neilime/ci/fix-publish
ci: fix publish workflow
2 parents 9ff978c + dc4315e commit ba0e34a

File tree

12 files changed

+57
-62
lines changed

12 files changed

+57
-62
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
nbproject/
33
vendor/
44
build/
5+
.phpdoc/
56
**/*.cache
67
**/composer.lock

.github/workflows/publish.yml

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,9 @@ jobs:
3838
steps:
3939
- uses: actions/checkout@v3
4040

41-
- name: Setup PHP, with composer and extensions
42-
uses: shivammathur/setup-php@v2
43-
with:
44-
php-version: 8.1
45-
extensions: mbstring
46-
coverage: pcov
47-
48-
- name: ♻️ Get composer cache directory
49-
id: composer-cache
50-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
51-
52-
- name: ♻️ Cache composer dependencies
53-
uses: actions/cache@v3
54-
with:
55-
path: ${{ steps.composer-cache.outputs.dir }}
56-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
57-
restore-keys: ${{ runner.os }}-composer-
58-
59-
- name: ⚙️ Install dependencies
60-
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
61-
62-
- name: Configure phpdoc-md
63-
run: |
64-
mkdir -p ./artifact/site/phpdoc;
65-
66-
php -d display_errors=0 -d error_reporting=0 -r "file_put_contents('.phpdoc-md','<?php
67-
return (object)[
68-
\'rootNamespace\' => \'CssLint\',
69-
\'destDirectory\' => \'./artifact/site/phpdoc\',
70-
\'format\' => \'github\',
71-
\'classes\' => '.var_export (array_values(array_filter(
72-
array_keys(require('./vendor/composer/autoload_classmap.php')),
73-
function(\$className) {
74-
return strpos(\$className, 'CssLint') === 0;
75-
}
76-
)), true).'
77-
];
78-
');
79-
";
80-
81-
- name: 📃 Execute phpdoc-md
41+
- name: 📃 Generate PHP documentation
8242
run: |
83-
vendor/bin/phpdoc-md -v
84-
mv ./artifact/site/phpdoc/README.md ./artifact/site/phpdoc/index.md
43+
docker run --rm -v $(pwd):/data phpdoc/phpdoc:3 -d ./src -t ./artifact/site/phpdoc
8544
8645
- uses: actions/upload-artifact@v3
8746
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/nbproject/
22
/vendor/
33
/build/
4+
/.phpdoc/
45
*.cache
56
composer.lock

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
FROM php:7.4-cli
1+
ARG VERSION=
22

3-
WORKDIR /app
3+
FROM php:${VERSION}-cli
44

5-
RUN apt-get -yqq update && \
6-
apt-get install -yqq --no-install-recommends libzip-dev zip && docker-php-ext-install zip \
7-
&& pecl install pcov && docker-php-ext-enable pcov
5+
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
6+
RUN \
7+
apt-get update -yqq; \
8+
apt-get install -yqq unzip; \
9+
pecl install pcov; \
10+
docker-php-ext-enable pcov;
811

912
RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;
1013

11-
12-
COPY --from=composer /usr/bin/composer /usr/bin/composer
13-

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.PHONY: help
2+
3+
help:
4+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
5+
6+
build-php: ## Build PHP image for given version
7+
@echo "Build php $(filter-out $@,$(MAKECMDGOALS))"
8+
@DOCKER_BUILDKIT=1 docker build -t "twbs-helper-php:$(filter-out $@,$(MAKECMDGOALS))" --build-arg "VERSION=$(filter-out $@,$(MAKECMDGOALS))" .
9+
10+
install:
11+
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader)
12+
13+
shell:
14+
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) bash)
15+
16+
test:
17+
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer test)
18+
19+
lint-fix:
20+
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer cbf)
21+
22+
ci:
23+
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer ci)
24+
25+
## Run PHP for given version
26+
define run-php
27+
@docker run -it --rm -u $(shell id -u):$(shell id -g) -v ${PWD}:/usr/src/app -w /usr/src/app twbs-helper-php:$(1)
28+
endef
29+
30+
#############################
31+
# Argument fix workaround
32+
#############################
33+
%:
34+
@:

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,27 @@
4949

5050
## Setup
5151

52+
`PHP_VERSION` is the version of php to use during the development. Example: `8.1`
53+
5254
```sh
53-
docker build -t php-css-lint .
54-
docker run --rm -it -v $(pwd):/app php-css-lint composer install
55+
make build-php PHP_VERSION
56+
make install PHP_VERSION
5557
```
5658

5759
## Running tests
5860

5961
```sh
60-
docker run --rm -it -v $(pwd):/app php-css-lint composer test
62+
make test PHP_VERSION
6163
```
6264

6365
## Fix code linting
6466

6567
```sh
66-
docker run --rm -it -v $(pwd):/app php-css-lint composer cbf
68+
make lint-fix PHP_VERSION
6769
```
6870

6971
## Running CI scripts
7072

7173
```sh
72-
docker run --rm -it -v $(pwd):/app php-css-lint composer ci
74+
make ci PHP_VERSION
7375
```

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
},
6363
"config": {
6464
"optimize-autoloader": true,
65-
"sort-packages": true
65+
"sort-packages": true,
66+
"allow-plugins": {
67+
"phpstan/extension-installer": true
68+
}
6669
},
6770
"extra": {
6871
"branch-alias": {

src/CssLint/Linter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class Linter
66
{
7-
87
public const CONTEXT_SELECTOR = 'selector';
98
public const CONTEXT_SELECTOR_CONTENT = 'selector content';
109
public const CONTEXT_NESTED_SELECTOR_CONTENT = 'nested selector content';

src/CssLint/Properties.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class Properties
66
{
7-
87
/**
98
* List of existing constructor prefix
109
* @var array

tests/TestSuite/CliTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class CliTest extends \PHPUnit\Framework\TestCase
66
{
7-
87
/**
98
* @var \CssLint\Cli
109
*/

0 commit comments

Comments
 (0)