Skip to content

Commit

Permalink
chore: improve workflow caching and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Jan 9, 2022
1 parent cbbcdd9 commit b7a70fc
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@

name: "build"

on: ["pull_request", "push"]
on:
push:
branches:
- "main"
tags:
- "*"
pull_request:
branches:
- "main"

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
COMPOSER_ROOT_VERSION: "1.99.99"
Expand All @@ -22,12 +36,14 @@ jobs:
coverage: "none"

- name: "Install dependencies (Composer)"
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"

- name: "Check syntax (php-parallel-lint)"
shell: "bash"
run: "./bin/devtools lint:syntax"

- name: "Check coding standards (PHP_CodeSniffer)"
shell: "bash"
run: "./bin/devtools lint:style"

static-analysis:
Expand All @@ -44,16 +60,19 @@ jobs:
coverage: "none"

- name: "Install dependencies (Composer)"
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"

- name: "Statically analyze code (PHPStan)"
shell: "bash"
run: "./bin/devtools analyze:phpstan"

- name: "Statically analyze code (Psalm)"
shell: "bash"
run: "./bin/devtools analyze:psalm -- --shepherd"

security-analysis:
name: "Security analysis"
needs: ["coding-standards", "static-analysis"]
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
Expand All @@ -66,9 +85,10 @@ jobs:
coverage: "none"

- name: "Install dependencies (Composer)"
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"

- name: "Analyze security of code (Psalm)"
shell: "bash"
run: "./vendor/bin/psalm --taint-analysis --report=build/logs/psalm.sarif"

- name: "Upload security analysis results to GitHub"
Expand All @@ -78,6 +98,7 @@ jobs:

code-coverage:
name: "Code coverage"
needs: ["coding-standards", "static-analysis"]
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
Expand All @@ -91,40 +112,33 @@ jobs:
ini-values: "memory_limit=-1"

- name: "Install dependencies (Composer)"
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v2"

- name: "Run unit tests (PHPUnit)"
shell: "bash"
run: "./bin/devtools test:coverage:ci"

- name: "Publish coverage report to Codecov"
uses: "codecov/codecov-action@v2.1.0"

unit-tests:
name: "Unit tests"
needs: ["code-coverage", "security-analysis"]
runs-on: ${{ matrix.operating-system }}
continue-on-error: ${{ matrix.experimental }}

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
operating-system:
- "macos-latest"
- "ubuntu-latest"
- "windows-latest"
dependencies:
- "lowest"
- "highest"
experimental:
- false
include:
- php-version: "8.1"
operating-system: "ubuntu-latest"
dependencies: "highest"
experimental: true
composer-options: "--ignore-platform-req=php"

steps:
- name: "Configure Git (for Windows)"
Expand All @@ -147,7 +161,6 @@ jobs:
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-options }}"

- name: "Run unit tests (PHPUnit)"
shell: "bash"
Expand Down

0 comments on commit b7a70fc

Please sign in to comment.