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

Sync back #21

Merged
merged 1 commit into from
Sep 30, 2024
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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "composer"
directory: "/" # Location of package manifests
schedule:
interval: "daily"

- package-ecosystem: "npm"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
87 changes: 87 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build
on:
workflow_call:

jobs:
build-php:
# See https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
runs-on: ubuntu-24.04
environment: testing

strategy:
matrix:
operating-system: [ ubuntu-24.04 ]
# Limited by https://github.com/shivammathur/setup-php#github-hosted-runners
php-version: [ '8.3' ]
dependency-stability: [ prefer-stable ]

name: build-laravel - PHP ${{ matrix.php-version }} (${{ matrix.operating-system }})

steps:
- uses: actions/checkout@v4.1.7 # Even better: using @<commit-SHA>

- name: Install PHP
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ matrix.php-version }}

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4.0.2
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
# could be extended in case multiple PHP versions are in use
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Restore vendor from cache
uses: actions/cache@v4.0.2
id: vendor-cache
with:
path: vendor
key: ${{ runner.os }}-build-${{ hashFiles('**/composer.lock') }}

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Install PHP Dependencies
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

build-node:
runs-on: ubuntu-24.04
environment: testing

strategy:
matrix:
operating-system: [ ubuntu-24.04 ]

steps:
- uses: actions/checkout@v4.1.7 # Even better: using @<commit-SHA>

- name: Setup Node
uses: actions/setup-node@v4.0.4
with:
node-version: 20
cache: 'npm'

- name: Install Node Dependencies
# TODO: Test, whether --ignore-scripts work here, as this is helping in hardening (preventing postinstall scripts)
run: npm ci

- name: Build Frontend Assets
run: npm run build

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4.4.0
with:
name: eventguru-build-${{ github.run_id }}
path: public/build
68 changes: 27 additions & 41 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Laravel Github action
name: Tests
on:
pull_request:
branches:
Expand All @@ -14,67 +14,56 @@ env:
DB_DATABASE: testing

jobs:
laravel-tests:
build:
uses: './.github/workflows/build.yaml'

php-tests:
needs: [ build ]
# See https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
runs-on: ubuntu-24.04
environment: testing

strategy:
matrix:
operating-system: [ubuntu-24.04]
operating-system: [ ubuntu-24.04 ]
# Limited by https://github.com/shivammathur/setup-php#github-hosted-runners
php-versions: [ '8.3' ]
php-version: [ '8.3' ]
dependency-stability: [ prefer-stable ]

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
name: php-tests - PHP ${{ matrix.php-version }} (${{ matrix.operating-system }})

steps:
- uses: actions/checkout@v4.1.7 # Even better: using @<commit-SHA>
- uses: actions/checkout@v4.1.7

- name: Start MySQL service
run: sudo systemctl start mysql.service
- name: Start MySQL service & create testing database
run: |
sudo systemctl start mysql.service
mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u"$DB_USER" -p"$DB_PASSWORD"

- name: Install PHP versions
- name: Install PHP
uses: shivammathur/setup-php@2.31.1
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-version }}

- name: Setup Node
uses: actions/setup-node@v4
- name: Download build artifact
id: download-build-artifact
uses: actions/download-artifact@v4.1.8
with:
node-version: 20
cache: 'npm'

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
# Pick up the folder from build.yaml Upload (name must match)
name: eventguru-build-${{ github.run_id }}
path: public/build

- uses: actions/cache@v4.0.2
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Cache PHP dependencies
- name: Restore vendor from Cache
uses: actions/cache@v4.0.2
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}

- name: Install PHP Dependencies
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Install Node Dependencies
# TODO: Test, whether --ignore-scripts work here, as this is helping in hardening (preventing postinstall scripts)
run: npm ci

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate

- name: Prepare Laravel Application
run: |
Expand All @@ -84,8 +73,5 @@ jobs:
- name: Run Migrations
run: php artisan migrate

- name: Build Frontend Assets
run: npm run build

- name: Execute tests (Unit and Feature tests) via PestPHP
run: php artisan test