Skip to content

Commit

Permalink
Added Github Actions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnavarrocarter committed Jul 25, 2020
1 parent f4734a4 commit c659aab
Show file tree
Hide file tree
Showing 10 changed files with 5,444 additions and 7 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@


# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Check Coding Standards"

on:
pull_request:
push:
branches:
- "master"

jobs:
coding-standards:
name: "Check Coding Standards"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "7.4"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Coding Standard"
run: "vendor/bin/php-cs-fixer fix --dry-run -vvv"
62 changes: 62 additions & 0 deletions .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Mutation tests"

on:
pull_request:
push:
branches:
- "master"

jobs:
mutation-tests:
name: "Mutation tests"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "7.4"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Infection"
run: "vendor/bin/infection"
continue-on-error: true
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
61 changes: 61 additions & 0 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "PHPUnit tests"

on:
pull_request:
push:
branches:
- "master"
jobs:
phpunit:
name: "PHPUnit tests"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "lowest"
- "highest"
- "locked"
php-version:
- "7.4"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 0

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Tests"
run: "vendor/bin/phpunit"
57 changes: 57 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Static Analysis by Psalm"

on:
pull_request:
push:
branches:
- "master"
jobs:
static-analysis-psalm:
name: "Static Analysis by Psalm"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "7.4"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2, cs2pr

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "psalm"
run: "vendor/bin/psalm --output-format=github --shepherd --stats"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/vendor
/.php_cs.cache
/composer.lock
.phpunit.result.cache
phpunit.xml
psalm.xml
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Legatus Crypto

Simple and secure cryptographic implementations for common tasks

[![Build Status](https://drone.mnavarro.dev/api/badges/legatus/crypto/status.svg)](https://drone.mnavarro.dev/legatus/crypto)
[![Type Coverage](https://shepherd.dev/github/legatus-php/crypto/coverage.svg)](https://shepherd.dev/github/legatus-php/crypto)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Flegatus-php%2Fcrypto%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/legatus-php/crypto/master)

## Installation
You can install the Event Dispatcher component using [Composer][composer]:
Expand All @@ -16,12 +17,38 @@ composer require legatus/crypto

```php
<?php
declare(strict_types=1);

// Quick example here
$key = Defuse\Crypto\Key::createNewRandomKey();
$cipher = new Legatus\Support\DefuseCipher($key);

$encrypted = $cipher->encrypt('message');

try {
$message = $cipher->decrypt($encrypted, 3600); // ttl is optional
} catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $e) {
// There is no access to a CPRNG
} catch (Legatus\Support\ExpiredCipher $e) {
// The message has passed the ttl
} catch (Legatus\Support\InvalidCipher $e) {
// The message is invalid
}
```

For more details you can check the [online documentation here][docs].

# Project status & release process

While this library is still under development, it is well tested and should be stable enough to use in production environments.

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as 0.2.*.

If you need to upgrade to a newer release cycle, check the [release history][releases] for a list of changes introduced by each further 0.x.0 version.

## Community
We still do not have a community channel. If you would like to help with that, you can let me know!

Expand All @@ -35,4 +62,5 @@ Please report security issues privately by email and give us a period of grace b
Legatus is a personal open source project led by Matías Navarro Carter and developed by contributors.

[composer]: https://getcomposer.org/
[docs]: https://legatus.mnavarro.dev/components/crypto
[docs]: https://legatus.dev/components/crypto
[releases]: https://github.com/legatus-php/crypto/releases
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@
"require-dev": {
"phpunit/phpunit": "^9.0",
"friendsofphp/php-cs-fixer": "^2.16",
"vimeo/psalm": "^3.7"
"vimeo/psalm": "^3.7",
"infection/infection": "^0.16.4"
},
"scripts": {
"lint": "php-cs-fixer fix --ansi",
"ci:style": "php-cs-fixer fix --dry-run -vvv --ansi",
"ci:test": "phpunit --testdox --coverage-text",
"ci:types": "psalm",
"ci:infection": "infection",
"ci": [
"@ci:types",
"@ci:test",
"@ci:style"
"@ci:unit",
"@ci:style",
"@ci:infection"
]
}
}

0 comments on commit c659aab

Please sign in to comment.