Skip to content
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

refactor: validation rules #861

Merged
merged 11 commits into from
Sep 30, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Sep 27, 2023

Description

  • put validation rules into the ValidationRules class
  • make password rules reusable

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the refactor Pull requests that refactor code label Sep 27, 2023
@kenjis kenjis marked this pull request as draft September 28, 2023 02:15
@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

  - Downloading rector/rector (0.18.4)
    Failed to download rector/rector from dist: curl error 23 while downloading https://codeload.github.com/rectorphp/rector/legacy.zip/d99a91176b7eb7f2b6d509a6486b3661c6dfd370: Failure writing output to destination
    Now trying to download from source
  - Syncing rector/rector (0.18.4) into cache
The disk hosting /home/runner/.composer has less than 100MiB of free space, this may be the cause of the following exception
Error: Failed to execute git clone --mirror -- '***github.com/rectorphp/rector.git' '/home/runner/.cache/composer/vcs/https---github.com-rectorphp-rector.git/'

Cloning into bare repository '/home/runner/.cache/composer/vcs/https---github.com-rectorphp-rector.git'...
fatal: write error: No space left on device
fatal: fetch-pack: invalid index-pack output


In Git.php line 472:
                                                                               
  Failed to execute git clone --mirror -- '***gi  
  thub.com/rectorphp/rector.git' '/home/runner/.cache/composer/vcs/https---gi  
  thub.com-rectorphp-rector.git/'                                              
                                                                               
  Cloning into bare repository '/home/runner/.cache/composer/vcs/https---gith  
  ub.com-rectorphp-rector.git'...                                              
  fatal: write error: No space left on device                                  
  fatal: fetch-pack: invalid index-pack output                                 
                                                                               

update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>...]

Error: Process completed with exit code 1.

https://github.com/codeigniter4/shield/actions/runs/6323482106/job/17200933174

@kenjis kenjis force-pushed the refactor-validation-rules branch 2 times, most recently from f0070f5 to 7f0d5b3 Compare September 28, 2023 03:02
@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

The composer cache was 49MB.
Screenshot 2023-09-28 11 53 37

@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

I separated the Composer cache for lowest dependencies, but still got No space left on device.

Screenshot 2023-09-28 12 13 08

Run actions/cache@v3
  with:
    path: /home/runner/.cache/composer/files
    key: Linux-composer-7c03de2df306f9299d0172425aef98e930e92b62f2384a646a9ef79f9b2d934f-
    restore-keys: Linux-composer-
    enableCrossOsArchive: false
    fail-on-cache-miss: false
    lookup-only: false
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
    COMPOSER_AUTH: {"github-oauth": {"github.com": "***"}}
    COMPOSER_CACHE_FILES_DIR: /home/runner/.cache/composer/files
Received 6286182 of 18869094 (33.3%), 6.0 MBs/sec
Cache Size: ~18 MB (18869094 B)
/usr/bin/tar -xf /home/runner/work/_temp/6478a5f4-548a-4525-8b7d-f12073007c27/cache.tzst -P -C /home/runner/work/shield/shield --use-compress-program unzstd
/usr/bin/tar: ../../../.cache/composer/files/rector/rector/5e59ef15f1b731d0d8daed7342cd64a8b40cc94b.zip: Wrote only 2560 of 10240 bytes
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/language-server-protocol: Cannot mkdir: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/language-server-protocol/bee555c8048b240c2c2f28255fef8f3efc814e2c.zip: Cannot open: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/advanced-json-rpc: Cannot mkdir: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/advanced-json-rpc/ee93f6a030a8ec4909ae17405ed90c75f9d0c59c.zip: Cannot open: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/amphp: Cannot mkdir: No space left on device
Error: No space left on device : '/home/runner/runners/2.309.0/_diag/pages/73043d58-15df-45b3-8b59-71fd6d300ffa_b5bf44b0-6ed1-5922-4ec3-7240bc7b5754_1.log'

https://github.com/codeigniter4/shield/actions/runs/6334017276/job/17203006457?pr=861

@paulbalandan
Copy link
Member

There is a sample workflow that deletes the used cache of merged PRs. We can use that.

@paulbalandan
Copy link
Member

Also, we can unify the naming of caches so that it will not create numerous caches.

@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

@paulbalandan What do you mean?
Why No space left on device occurs? How can we free the disk space?

@paulbalandan
Copy link
Member

We can manually delete the used cache for merged PRs.

image

Just click on the trash icon on the branches with refs/pull/<PR no.>/merge

@paulbalandan
Copy link
Member

We can use this sample workflow to delete the caches of merged PRs.
https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries

@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

Okay, I will remove cache manually.

$ gh api -H "Accept: application/vnd.github+json" "/repos/codeigniter4/shield/actions/cache/usage"
{
  "full_name": "codeigniter4/shield",
  "active_caches_size_in_bytes": 173837775,
  "active_caches_count": 61
}

@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

I removed some caches, but the cache usage is the same.

$ gh api -H "Accept: application/vnd.github+json" "/repos/codeigniter4/shield/actions/cache/usage"
{
  "full_name": "codeigniter4/shield",
  "active_caches_size_in_bytes": 173837775,
  "active_caches_count": 61
}

Updated.

$ gh api -H "Accept: application/vnd.github+json" "/repos/codeigniter4/shield/actions/cache/usage"
{
  "full_name": "codeigniter4/shield",
  "active_caches_size_in_bytes": 119023390,
  "active_caches_count": 37
}

@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

Again No space left on device.

Run actions/cache@v3
  with:
    path: /home/runner/.cache/composer/files
    key: Linux-composer-7c03de2df306f9299d0172425aef98e930e92b62f2384a646a9ef79f9b2d934f-
    restore-keys: Linux-composer-
    enableCrossOsArchive: false
    fail-on-cache-miss: false
    lookup-only: false
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
    COMPOSER_AUTH: {"github-oauth": {"github.com": "***"}}
    COMPOSER_CACHE_FILES_DIR: /home/runner/.cache/composer/files
Received 0 of 18869094 (0.0%), 0.0 MBs/sec
Cache Size: ~18 MB (18869094 B)
/usr/bin/tar -xf /home/runner/work/_temp/c47b14a5-78f2-4467-82cb-f0667f0a201d/cache.tzst -P -C /home/runner/work/shield/shield --use-compress-program unzstd
/usr/bin/tar: ../../../.cache/composer/files/rector/rector/5e59ef15f1b731d0d8daed7342cd64a8b40cc94b.zip: Wrote only 8704 of 10240 bytes
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/language-server-protocol: Cannot mkdir: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/language-server-protocol/bee555c8048b240c2c2f28255fef8f3efc814e2c.zip: Cannot open: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/advanced-json-rpc: Cannot mkdir: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/felixfbecker/advanced-json-rpc/ee93f6a030a8ec4909ae17405ed90c75f9d0c59c.zip: Cannot open: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/amphp: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/amphp: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/amphp/byte-stream: Cannot mkdir: No such file or directory
/usr/bin/tar: ../../../.cache/composer/files/amphp: Cannot mkdir: No space left on device
/usr/bin/tar: ../../../.cache/composer/files/amphp/byte-stream/24823ac0e49e56800f97cb0f4e852334fc3a60e0.zip: Cannot open: No such file or directory
Error: Failed to create step summary using 'GITHUB_STEP_SUMMARY': No space left on device : '/home/runner/runners/2.309.0/_diag/Worker_20230928-040404-utc.log'
Error: No space left on device : '/home/runner/runners/2.309.0/_diag/pages/1db4ff28-32bb-43f4-b866-6074ce04f994_351f6ddc-12f9-5119-6975-2ab1c53114b8_1.log'

https://github.com/codeigniter4/shield/actions/runs/6334017276/job/17203911560?pr=861

@kenjis kenjis added the help wanted Extra attention is needed label Sep 28, 2023
@kenjis kenjis force-pushed the refactor-validation-rules branch 3 times, most recently from 67c7c1d to b319800 Compare September 28, 2023 04:45
@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

@kenjis kenjis removed the help wanted Extra attention is needed label Sep 28, 2023
@kenjis kenjis mentioned this pull request Sep 28, 2023
1 task
@kenjis
Copy link
Member Author

kenjis commented Sep 28, 2023

I created a new PR for GitHub Actions. #863

@kenjis kenjis marked this pull request as ready for review September 28, 2023 05:07
@@ -203,26 +203,36 @@ class Auth extends BaseConfig
* The validation rules for username
* --------------------------------------------------------------------
*
* @var string[]
* Do not use string rules like `required|valid_email`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,
shouldn't the changes be applied to the documentation?

//     'rules' => 'required|max_length[30]|min_length[3]|regex_match[/\A[a-zA-Z0-9\.]+\z/]',
'rules' => 'required|max_byte[72]',
// and ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@datamweb datamweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks🥀.

@kenjis kenjis merged commit 1d9a659 into codeigniter4:develop Sep 30, 2023
32 checks passed
@kenjis kenjis deleted the refactor-validation-rules branch September 30, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants