Skip to content

Commit

Permalink
Moved CI to GHA.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Nov 4, 2024
1 parent fe521df commit 2369914
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 56 deletions.
54 changes: 0 additions & 54 deletions .circleci/config.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Ignore files for distribution archives.

/.circleci export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main
- 'feature/**'
workflow_dispatch:
inputs:
enable_terminal:
type: boolean
description: 'Enable terminal session.'
required: false
default: false

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Set up Docker Compose
run: docker compose up -d --build

- name: Copy codebase into container
run: |
container_id="$(docker compose ps -q phpserver)"
docker cp -L . "${container_id}":/app/
- name: Install Composer dependencies
run: docker compose exec phpserver composer install --ansi --no-suggest

- name: Lint code
run: docker compose exec phpserver composer lint
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}

- name: Restart server with Xdebug enabled
run: XDEBUG_ENABLE=true docker compose up -d phpserver

- name: Run tests with PHPUnit
run: docker compose exec -T -e XDEBUG_MODE=coverage phpserver vendor/bin/phpunit
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}

- name: Run tests with Behat
run: docker compose exec -T -e XDEBUG_MODE=coverage phpserver vendor/bin/behat
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}

- name: Process test logs and artifacts
run: |
mkdir -p /tmp/logs
if docker compose ps --services --filter "status=running" | grep -q phpserver && docker compose exec phpserver test -d /app/.logs; then
docker compose cp phpserver:/app/.logs/. "/tmp/logs/"
fi
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: artifacts
path: /tmp/logs

- name: Upload logs as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: /tmp/logs
include-hidden-files: true
if-no-files-found: error

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
if: ${{ env.CODECOV_TOKEN != '' }}
with:
files: |
/tmp/logs/coverage/behat/cobertura.xml
/tmp/logs/coverage/phpunit/cobertura.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Setup tmate session
if: ${{ !cancelled() && github.event.inputs.enable_terminal }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 5
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

[![GitHub Issues](https://img.shields.io/github/issues/drevops/behat-screenshot.svg)](https://github.com/drevops/behat-screenshot/issues)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/drevops/behat-screenshot.svg)](https://github.com/drevops/behat-screenshot/pulls)
[![CircleCI](https://circleci.com/gh/drevops/behat-screenshot.svg?style=shield)](https://circleci.com/gh/drevops/behat-screenshot)
[![Test](https://github.com/drevops/behat-screenshot/actions/workflows/test.yml/badge.svg)](https://github.com/drevops/behat-screenshot/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/drevops/behat-screenshot/graph/badge.svg?token=UN930S8FGC)](https://codecov.io/gh/drevops/behat-screenshot)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/behat-screenshot)
![LICENSE](https://img.shields.io/github/license/drevops/behat-screenshot)
Expand Down

0 comments on commit 2369914

Please sign in to comment.