Skip to content
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
40 changes: 40 additions & 0 deletions .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: generate

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'

- name: Checkout
uses: actions/checkout@v2

- name: Generate
run: make

- name: Count changes
id: changes
run: |
git add -N .
echo "::set-output name=count::$(git diff --name-only | wc -l)"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update Error Code
delete-branch: true
title: Update Error Code
body: |
Error codes have been updated.

- https://github.com/postgres/postgres/blob/master/src/backend/utils/errcodes.txt
if: ${{ steps.changes.outputs.count > 0 }}
7 changes: 5 additions & 2 deletions tools/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
$const = array();

while ($row = fgets(STDIN)) {
if (preg_match('/^([0-9A-Z]{5}) +[SWE] +[^ ]+? +([a-z_]+)$/', $row, $matches)) {
if (preg_match('/^Section: (Class .*)$/', $row, $matches)) {
$const[] = '';
$const[] = " // {$matches[1]}";
} elseif (preg_match('/^([0-9A-Z]{5}) +[SWE] +[^ ]+? +([a-z_]+)$/', $row, $matches)) {
$key = strtoupper($matches[2]);
if (isset($codes[$key])) {
$key .= '_EXCEPTION';
Expand All @@ -14,7 +17,7 @@
}
}

$const = implode(PHP_EOL, $const);
$const = trim(implode(PHP_EOL, $const), PHP_EOL);

echo <<<EOD
<?php
Expand Down