RSS Git Download  Clone
Raw Blame History
name: Build
on: [push, pull_request]

jobs:
  backend:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        php: [8.1]

    steps:
      - uses: actions/checkout@v2

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

      - name: Cache Composer packages
        id: composer-cache
        uses: actions/cache@v2
        with:
          path: vendor
          key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-php-

      - name: Install dependencies
        run: composer install --prefer-dist --no-progress

      - name: Run unit test suite
        run: composer run-script unit

      - name: Validate coding standards
        run: composer run-script cs

      - name: Run linters
        run: composer run-script lint

      - name: Run static analysis
        run: composer run-script stan

  frontend:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup Node.js environment
        uses: actions/setup-node@v2.5.1
        with:
          node-version: '16'

      - name: Install frontend dependencies
        run: npm install

      - name: Run frontend test suite
        run: npm test

  acceptance:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Cache Composer packages
        id: composer-cache
        uses: actions/cache@v2
        with:
          path: vendor
          key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-php-

      - name: Setup Node.js environment
        uses: actions/setup-node@v2.5.1
        with:
          node-version: '16'

      - name: Install dependencies
        run: composer install --prefer-dist --no-progress && npm install

      - name: Build frontend assets
        run: npm run build

      - name: Run application server
        run: echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | sudo tee /etc/apt/sources.list.d/symfony-cli.list && sudo apt update && sudo apt install symfony-cli && APP_ENV=prod DEFAULT_REPOSITORY_DIR=${{ github.workspace }}/tests/fixtures symfony server:start --port=8880 -d

      - name: Run Cypress acceptance tests
        uses: cypress-io/github-action@v2

  release:
    if: startsWith(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    needs: [backend, frontend]
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js environment
        uses: actions/setup-node@v2.5.1
        with:
          node-version: '16'

      - name: Install frontend dependencies
        run: npm install

      - name: Build package
        run: make build

      - name: Rename package to current tag
        run: mv build.zip gitlist-${{ github.ref_name }}.zip

      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          generate_release_notes: true
          files: gitlist-${{ github.ref_name }}.zip