Skip to content

Improve CI #3

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
block_comment_start = /*
block_comment = *
block_comment_end = */

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.json]
indent_size = 2
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/Tests export-ignore
/.* export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/Tests export-ignore
/phpunit.xml.dist export-ignore
181 changes: 181 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: "Integrate"

on:
push:
branches:
- "main"
- "develop"
pull_request:
branches:
- "main"
- "develop"
# Add [skip ci] to commit message to skip CI.

permissions:
contents: "read"

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
byte_level:
name: "0️⃣ Byte-level"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Check file permissions"
run: |
test "$(find . -type f -not -path './.git/*' -executable)" = ""

- name: "Find non-printable ASCII characters"
run: |
! LC_ALL=C.UTF-8 find . -type f -name '*.php' -print0 | xargs -0 -- grep -PHn '[^ -~]'

syntax_errors:
name: "1️⃣ Syntax errors"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
coverage: "none"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- name: "Check source code for syntax errors"
run: "composer exec -- parallel-lint Src/ Tests/"

unit_tests:
name: "2️⃣ Unit and functional tests"
needs:
- "byte_level"
- "syntax_errors"
strategy:
#fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
dependencies:
- "lowest"
- "highest"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Execute unit tests"
run: "composer run-script test"

# - name: "Send coverage to Coveralls"
# env:
# COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# if: "${{ env.COVERALLS_REPO_TOKEN && matrix.php-version == '8.0' && matrix.dependencies == 'highest' }}"
# run: |
# wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.2/php-coveralls.phar"
# php ./php-coveralls.phar -v

static_analysis:
name: "3️⃣ Static Analysis"
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
coverage: "none"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Check JSON files"
run: |
find . -type f -name '*.json' | xargs -t -L 1 -- php -r 'json_decode(file_get_contents($argv[1]), null, 512, JSON_THROW_ON_ERROR);'

- name: "Validate Composer configuration"
run: "composer validate --no-interaction --strict"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- name: "Check PSR-4 mapping"
run: "composer dump-autoload --no-interaction --optimize --strict-psr"

- name: "Perform static analysis"
run: "composer run-script phpstan"

coding_standards:
name: "4️⃣ Coding Standards"
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
coverage: "none"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Check EditorConfig configuration"
run: "test -f .editorconfig"

- name: "Check adherence to EditorConfig"
uses: "greut/eclint-action@v0"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- name: "Check coding style"
run: "composer exec -- phpcs --standard=PSR12 -s Src/ Tests/"

exported_files:
name: "5️⃣ Exported files"
needs:
- "byte_level"
- "syntax_errors"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Check exported files"
run: |
EXPECTED="CHANGELOG.md,LICENSE,README.md,composer.json"
CURRENT="$(git archive HEAD | tar --list --exclude="Src" --exclude="Src/*" | paste --serial --delimiters=",")"
echo "CURRENT =${CURRENT}"
echo "EXPECTED=${EXPECTED}"
test "${CURRENT}" = "${EXPECTED}"
42 changes: 0 additions & 42 deletions .github/workflows/php.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
vendor
.phpunit.result.cache
/.phpunit.result.cache
/vendor/
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Renamed the package in Packagist from `php-weather/common` to `php-weather/core`(#1)
* Renamed the package in Packagist from `php-weather/common` to `php-weather/core`(#1)
2 changes: 1 addition & 1 deletion Src/Common/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ public function toArray(): array
{
return get_object_vars($this);
}
}
}
2 changes: 1 addition & 1 deletion Src/Common/UnitConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ public static function mapPrecipitation(float $precipitation, string $from, stri
},
};
}
}
}
2 changes: 1 addition & 1 deletion Src/Common/Weather.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ public function setDewPoint(?float $dewPoint): self

return $this;
}
}
}
2 changes: 1 addition & 1 deletion Src/Common/WeatherCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ private function sortByDate(Weather $a, Weather $b): int

return ($a->getUtcDateTime() < $b->getUtcDateTime()) ? -1 : 1;
}
}
}
2 changes: 1 addition & 1 deletion Src/Common/WeatherQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ public function getUnits(): string
{
return $this->units;
}
}
}
2 changes: 1 addition & 1 deletion Src/Constants/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class Type
public const CURRENT = 'current';
public const HISTORICAL = 'historical';
public const FORECAST = 'forecast';
}
}
2 changes: 1 addition & 1 deletion Src/Constants/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class Unit
public const PRECIPITATION_MM = 'mm';
public const PRECIPIATION_kgm = 'kgm';
public const PRECIPITAION_INCHES = 'inches';
}
}
2 changes: 1 addition & 1 deletion Src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

interface Exception extends Throwable
{
}
}
2 changes: 1 addition & 1 deletion Src/Exception/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class ClientException extends WeatherException
{

}
}
2 changes: 1 addition & 1 deletion Src/Exception/InvalidCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class InvalidCredentials extends ClientException
{

}
}
2 changes: 1 addition & 1 deletion Src/Exception/InvalidValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class InvalidValueException extends WeatherException
{

}
}
2 changes: 1 addition & 1 deletion Src/Exception/NoWeatherData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class NoWeatherData extends WeatherException
{

}
}
2 changes: 1 addition & 1 deletion Src/Exception/QuotaExceeded.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class QuotaExceeded extends ClientException
{

}
}
2 changes: 1 addition & 1 deletion Src/Exception/ServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class ServerException extends WeatherException
{

}
}
2 changes: 1 addition & 1 deletion Src/Exception/WeatherException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
class WeatherException extends \Exception implements Exception
{

}
}
2 changes: 1 addition & 1 deletion Src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public function getHistoricalTimeLine(WeatherQuery $query): WeatherCollection;
* @return Source[]
*/
public function getSources(): array;
}
}
2 changes: 1 addition & 1 deletion Src/Weather.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public function setIcon(?string $icon): self;
public function getSources(): array;
public function addSource(Source $source): self;
public function removeSource(Source $source): self;
}
}
2 changes: 1 addition & 1 deletion Src/WeatherCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public function hasForecast(): bool;
* @return Weather[];
*/
public function getForecast(): array;
}
}
Loading