From 349d6515509866f9c3efc2ae44d990ccb10bd626 Mon Sep 17 00:00:00 2001 From: Lewis Larsen Date: Thu, 13 Jun 2024 22:30:06 +0100 Subject: [PATCH] added gh actions scripts --- github/workflows/code-fixing.yml | 29 +++++++++++++ github/workflows/dependabot-auto-merge.yml | 32 +++++++++++++++ github/workflows/test-suite.yml | 47 ++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 github/workflows/code-fixing.yml create mode 100644 github/workflows/dependabot-auto-merge.yml create mode 100644 github/workflows/test-suite.yml diff --git a/github/workflows/code-fixing.yml b/github/workflows/code-fixing.yml new file mode 100644 index 00000000..a8f7b1f0 --- /dev/null +++ b/github/workflows/code-fixing.yml @@ -0,0 +1,29 @@ +name: Fix code style + +on: + push: + branches: [main] + pull_request: + branches: [main] + paths: + - '**.php' + +jobs: + php-code-styling: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: ${{ github.repository }} + token: ${{ secrets.PAT }} + ref: ${{ github.head_ref }} + + - name: Fix PHP code style issues + uses: aglipanci/laravel-pint-action@2.1.0 + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Ensured code style consistency. diff --git a/github/workflows/dependabot-auto-merge.yml b/github/workflows/dependabot-auto-merge.yml new file mode 100644 index 00000000..5a3c8795 --- /dev/null +++ b/github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: Dependabot auto-merge +on: pull_request_target + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.3.5 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge Dependabot PRs for semver-minor updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Auto-merge Dependabot PRs for semver-patch updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/github/workflows/test-suite.yml b/github/workflows/test-suite.yml new file mode 100644 index 00000000..39d1b35e --- /dev/null +++ b/github/workflows/test-suite.yml @@ -0,0 +1,47 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + phpunit: + runs-on: ubuntu-latest + container: + image: kirschbaumdevelopment/laravel-test-runner:8.3 + + services: + postgres: + image: postgres:15.1 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: vanguard + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Install composer dependencies + run: | + composer install --no-scripts + + - name: Prepare Laravel Application + run: | + cp .env.example.ci .env + php artisan key:generate + + - name: Install npm dependencies + run: npm install + + - name: Build assets + run: npm run build + + - name: Run Tests + run: vendor/bin/pest