Skip to content

Commit

Permalink
Split up updating of status codes and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Nov 26, 2022
1 parent 2112f34 commit e1a5519
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Daily HTTP spec update
name: Daily HTTP Method spec update

on:
workflow_dispatch:
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Install dependencies
run: composer install
- name: Run standard update command
run: composer update-spec -- --type=http
run: composer update-spec -- --type=http-methods
- name: Run CSFixer
run: composer cs:fix
- name: Create Pull Request
Expand All @@ -23,7 +23,7 @@ jobs:
with:
commit-message: Automatic spec update from upstream changes
delete-branch: true
title: 'Automatic Http spec update'
title: 'Automatic Http method spec update'
body: |
This PR makes sure the content of this package is updated with upstream changes in the specs.
labels: |
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/update-spec-http-status-codes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Daily HTTP status code spec update

on:
workflow_dispatch:
schedule:
- cron: '55 17 * * *'

jobs:
update-specs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: composer install
- name: Run standard update command
run: composer update-spec -- --type=http-status-codes
- name: Run CSFixer
run: composer cs:fix
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
commit-message: Automatic spec update from upstream changes
delete-branch: true
title: 'Automatic Http status code spec update'
body: |
This PR makes sure the content of this package is updated with upstream changes in the specs.
labels: |
spec-update
automated pr
reviewers: prinsfrank
3 changes: 2 additions & 1 deletion dev/DataSource/SpecType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum SpecType
{
case COUNTRY;
case CURRENCY;
case HTTP;
case HTTP_STATUS_CODES;
case HTTP_METHODS;
case LANGUAGE;
}
19 changes: 12 additions & 7 deletions dev/SpecUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ class SpecUpdater
];

/** @var array<class-string<DataSource>> */
public const HTTP_SOURCES = [
public const HTTP_STATUS_CODE_SOURCES = [
HttpStatusCodeSource::class,
];

/** @var array<class-string<DataSource>> */
public const HTTP_METHOD_SOURCES = [
HttpMethodSource::class,
];

Expand All @@ -73,12 +77,13 @@ public static function update(Event $event): void
$type = $event->getArguments()[0] ?? throw new InvalidArgumentException('Please specify the type with "-- --type=' . implode(',', UnitEnum::names(SpecType::class)) . '"');
$type = str_starts_with($type, '--type=') === false ? throw new InvalidArgumentException('Please specify the type with "-- --type=' . implode(',', UnitEnum::names(SpecType::class)) . '"') : substr($type, 7);

$sources = match (UnitEnum::tryFromKey(SpecType::class, strtoupper($type))) {
SpecType::COUNTRY => self::COUNTRY_SOURCES,
SpecType::CURRENCY => self::CURRENCY_SOURCES,
SpecType::HTTP => self::HTTP_SOURCES,
SpecType::LANGUAGE => self::LANGUAGE_SOURCES,
default => throw new InvalidArgumentException('Automatic spec updating for type "' . $type . '" not implemented'),
$sources = match (UnitEnum::tryFromKey(SpecType::class, strtoupper(str_replace('-', '_', $type)))) {
SpecType::COUNTRY => self::COUNTRY_SOURCES,
SpecType::CURRENCY => self::CURRENCY_SOURCES,
SpecType::HTTP_STATUS_CODES => self::HTTP_STATUS_CODE_SOURCES,
SpecType::HTTP_METHODS => self::HTTP_METHOD_SOURCES,
SpecType::LANGUAGE => self::LANGUAGE_SOURCES,
default => throw new InvalidArgumentException('Automatic spec updating for type "' . $type . '" not implemented'),
};

/** @var class-string<DataSource> $sourceFQN */
Expand Down

0 comments on commit e1a5519

Please sign in to comment.