Skip to content

ci: fix publish workflow #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2022
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
nbproject/
vendor/
build/
.phpdoc/
**/*.cache
**/composer.lock
45 changes: 2 additions & 43 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,50 +38,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: mbstring
coverage: pcov

- name: ♻️ Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: ♻️ Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: ⚙️ Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader

- name: Configure phpdoc-md
run: |
mkdir -p ./artifact/site/phpdoc;

php -d display_errors=0 -d error_reporting=0 -r "file_put_contents('.phpdoc-md','<?php
return (object)[
\'rootNamespace\' => \'CssLint\',
\'destDirectory\' => \'./artifact/site/phpdoc\',
\'format\' => \'github\',
\'classes\' => '.var_export (array_values(array_filter(
array_keys(require('./vendor/composer/autoload_classmap.php')),
function(\$className) {
return strpos(\$className, 'CssLint') === 0;
}
)), true).'
];
');
";

- name: 📃 Execute phpdoc-md
- name: 📃 Generate PHP documentation
run: |
vendor/bin/phpdoc-md -v
mv ./artifact/site/phpdoc/README.md ./artifact/site/phpdoc/index.md
docker run --rm -v $(pwd):/data phpdoc/phpdoc:3 -d ./src -t ./artifact/site/phpdoc

- uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/nbproject/
/vendor/
/build/
/.phpdoc/
*.cache
composer.lock
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM php:7.4-cli
ARG VERSION=

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

RUN apt-get -yqq update && \
apt-get install -yqq --no-install-recommends libzip-dev zip && docker-php-ext-install zip \
&& pecl install pcov && docker-php-ext-enable pcov
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
RUN \
apt-get update -yqq; \
apt-get install -yqq unzip; \
pecl install pcov; \
docker-php-ext-enable pcov;

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


COPY --from=composer /usr/bin/composer /usr/bin/composer

34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.PHONY: help

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

build-php: ## Build PHP image for given version
@echo "Build php $(filter-out $@,$(MAKECMDGOALS))"
@DOCKER_BUILDKIT=1 docker build -t "twbs-helper-php:$(filter-out $@,$(MAKECMDGOALS))" --build-arg "VERSION=$(filter-out $@,$(MAKECMDGOALS))" .

install:
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader)

shell:
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) bash)

test:
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer test)

lint-fix:
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer cbf)

ci:
@$(call run-php,$(filter-out $@,$(MAKECMDGOALS)) composer ci)

## Run PHP for given version
define run-php
@docker run -it --rm -u $(shell id -u):$(shell id -g) -v ${PWD}:/usr/src/app -w /usr/src/app twbs-helper-php:$(1)
endef

#############################
# Argument fix workaround
#############################
%:
@:
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,27 @@

## Setup

`PHP_VERSION` is the version of php to use during the development. Example: `8.1`

```sh
docker build -t php-css-lint .
docker run --rm -it -v $(pwd):/app php-css-lint composer install
make build-php PHP_VERSION
make install PHP_VERSION
```

## Running tests

```sh
docker run --rm -it -v $(pwd):/app php-css-lint composer test
make test PHP_VERSION
```

## Fix code linting

```sh
docker run --rm -it -v $(pwd):/app php-css-lint composer cbf
make lint-fix PHP_VERSION
```

## Running CI scripts

```sh
docker run --rm -it -v $(pwd):/app php-css-lint composer ci
make ci PHP_VERSION
```
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
Expand Down
1 change: 0 additions & 1 deletion src/CssLint/Linter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class Linter
{

public const CONTEXT_SELECTOR = 'selector';
public const CONTEXT_SELECTOR_CONTENT = 'selector content';
public const CONTEXT_NESTED_SELECTOR_CONTENT = 'nested selector content';
Expand Down
1 change: 0 additions & 1 deletion src/CssLint/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class Properties
{

/**
* List of existing constructor prefix
* @var array
Expand Down
1 change: 0 additions & 1 deletion tests/TestSuite/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class CliTest extends \PHPUnit\Framework\TestCase
{

/**
* @var \CssLint\Cli
*/
Expand Down
1 change: 0 additions & 1 deletion tests/TestSuite/LinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class LinterTest extends \PHPUnit\Framework\TestCase
{

/**
* @var \CssLint\Linter
*/
Expand Down
1 change: 0 additions & 1 deletion tests/TestSuite/PropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class PropertiesTest extends \PHPUnit\Framework\TestCase
{

public function testShouldReturnTrueWhenGivenStandardPropertyExists()
{
$oProperties = new \CssLint\Properties();
Expand Down