Verified Commit 51bffafd authored by Elias Häußler's avatar Elias Häußler 🐛
Browse files

[TASK] Add GitHub workflows

parent f7f6d856
* text=auto
/bin export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.gitlab-ci.yml export-ignore
/*.gitlab-ci.yml export-ignore
/.php_cs export-ignore
/mkdocs.yml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/phpunit.coverage.xml export-ignore
* text=auto
/.github export-ignore
/bin export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.gitlab-ci.yml export-ignore
/*.gitlab-ci.yml export-ignore
/.php_cs export-ignore
/mkdocs.yml export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/phpunit.coverage.xml export-ignore
/sonar-project.properties export-ignore
---
name: Bug report
about: Create a report to help improve the package
title: "[BUG]"
labels: bug
assignees: ''
---
**Description**
A clear and concise description of what the bug is.
**Steps to reproduce**
If possible, describe steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Environment**
- PHP version: [e.g. 8.0.11]
- Package version: [e.g. 1.1.0]
- OS: [macOS 11.4, Windows 10]
**Additional context**
Add any other context about the problem here.
---
name: Feature request
about: Suggest an idea for this package
title: "[FEATURE]"
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
name: CGL
on: [push, pull_request]
jobs:
cgl:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Prepare environment
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: composer:v2
# Install dependencies
- name: Install Composer dependencies
run: composer install --no-progress
# Linting
- name: Lint composer.json
run: composer normalize --dry-run
- name: Lint PHP
run: composer lint -- --dry-run
# SCA
- name: SCA PHP
run: composer sca -- --error-format github
name: CGL
on:
push:
branches:
- master
jobs:
render:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
env:
COMPOSE_FILE: docs/build/docker-compose.yaml
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Render docs
- name: Build container
run: docker-compose build --pull
- name: Render HTML
run: docker-compose run --rm docs build
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: rendered-docs
path: site/
deploy:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
needs: build
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: rendered-docs
# Prepare SSH connection
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Add known hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
# Upload
- name: Deploy
run: 'rsync -avz --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r site/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/eliashae/html/docs.elias-haeussler.de/composer-update-reporter/'
name: Release
on:
push:
tags:
- '*'
jobs:
# Job: Create release
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Check if tag is valid
- name: Check tag
run: |
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
exit 1
fi
# Create Changelog
- name: Create changelog
id: create-changelog
uses: heinrichreimer/github-changelog-generator-action@v2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
addSections: '{"documentation":{"prefix":"### Documentation","labels":["documentation"]},"feature":{"prefix":"### Added","labels":["feature"]}}'
breakingLabel: "### Breaking"
enhancementLabel: "### Changed"
bugsLabel: "### Fixed"
deprecatedLabel: "### Deprecated"
removedLabel: "### Removed"
securityLabel: "### Security"
prLabel: "### Other pull requests"
onlyLastTag: true
issues: false
issuesWoLabels: false
pullRequests: true
prWoLabels: true
stripHeaders: false
stripGeneratorNotice: true
- name: Print changelog to console
run: cat CHANGELOG.md
# Create release
- name: Create release
id: create-release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.create-changelog.outputs.changelog }}
name: Tests
on: [push, pull_request]
jobs:
# Job: Run unit tests
tests:
name: PHP ${{ matrix.php-version }} & Composer ${{ matrix.composer-version }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- php-version: 7.1
composer-version: 1
- php-version: 7.1
composer-version: 2
- php-version: 7.2
composer-version: 1
- php-version: 7.2
composer-version: 2
- php-version: 7.3
composer-version: 1
- php-version: 7.3
composer-version: 2
- php-version: 7.4
composer-version: 1
- php-version: 7.4
composer-version: 2
- php-version: 8.0
composer-version: 1
- php-version: 8.0
composer-version: 2
coverage: 1
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Prepare environment
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v${{ matrix.composer-version }}
coverage: pcov
# Define Composer cache
- name: Get Composer cache directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Define Composer cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: tests-php-${{ matrix.php-version }}-composer-${{ matrix.composer-version }}
restore-keys: |
tests-php-${{ matrix.php-version }}-composer-
# Install dependencies
- name: Install Composer and dependencies
run: composer require --dev --no-progress "composer/composer:^${{ matrix.composer-version }}"
# Run tests
- name: Build coverage directory
run: mkdir -p .build/coverage
- name: Run tests with coverage
run: composer test:coverage
if: ${{ matrix.coverage }}
- name: Run tests without coverage
run: composer test
if: ${{ !matrix.coverage }}
# Report coverage
- name: Fix coverage path
working-directory: .build/coverage
run: sed -i 's/\/home\/runner\/work\/composer-update-reporter\/composer-update-reporter\//\/github\/workspace\//g' clover.xml
if: ${{ matrix.coverage }}
- name: Run SonarCloud scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: ${{ matrix.coverage }}
# Job: Run unit tests with lowest installed dependency versions
tests-lowest:
name: '[test-lowest] PHP ${{ matrix.php-version }} & Composer ${{ matrix.composer-version }}'
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php-version: ["7.1", "7.2", "7.3", "7.4", "8.0"]
composer-version: ["1", "2"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# Prepare environment
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v${{ matrix.composer-version }}
coverage: none
# Define Composer cache
- name: Get Composer cache directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Define Composer cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: tests-lowest-php-${{ matrix.php-version }}-composer-${{ matrix.composer-version }}
restore-keys: |
tests-lowest-php-${{ matrix.php-version }}-composer-
# Install dependencies
- name: Install Composer and dependencies
run: composer require --dev --no-progress --prefer-lowest "composer/composer:^${{ matrix.composer-version }}"
# Run tests
- name: Run tests
run: |
mkdir -p .build/coverage
composer test
sonar.projectKey=eliashaeussler_composer-update-reporter
sonar.organization=eliashaeussler
sonar.sources=.
sonar.exclusions=**/tests/**,**/.build/**
sonar.php.coverage.reportPaths=.build/coverage/clover.xml
sonar.php.tests.reportPaths=.build/coverage/junit.xml
sonar.coverage.exclusions=*.php,bin/**,docs/**
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment