Skip to content

test

test #302

Workflow file for this run

name: main
on: [push, workflow_dispatch]
jobs:
main:
name: main
runs-on: ubuntu-22.04
permissions:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: prepare
id: prepare
run: |
echo $GITHUB_REF_NAME
echo "branch=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
- uses: "google-github-actions/auth@v2"
with:
project_id: ${{ secrets.GCLOUD_PROJECT_ID_TEST }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER_TEST }}
service_account: ${{ secrets.SERVICE_ACCOUNT_CLOUD_STORAGE_TEST }}
- name: build
env:
GCLOUD_PROJECT_ID: ${{secrets.GCLOUD_PROJECT_ID_TEST}}
GCLOUD_BUCKET_ID: ${{secrets.GCLOUD_BUCKET_ID_TEST}}
DATABASE_URL: ${{secrets.DATABASE_URL_TEST}}
NEON_API_KEY: ${{secrets.NEON_API_KEY}}
NEON_PROJECT_ID: ${{secrets.NEON_PROJECT_ID_TEST}}
run: |
echo "${{ steps.prepare.outputs.branch }}"
docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --no-cache
docker compose up -d
echo -e "\nGCLOUD_PROJECT_ID=$GCLOUD_PROJECT_ID" >> symfony/.env
echo "GCLOUD_BUCKET_ID=${{github.run_id}}--$GCLOUD_BUCKET_ID" >> symfony/.env
echo "GOOGLE_APPLICATION_CREDENTIALS=/var/www/symfony/google_credentials.json" >> symfony/.env
echo "DATABASE_URL=$DATABASE_URL" >> symfony/.env
touch symfony/.env.test.local
echo "DATABASE_URL=$DATABASE_URL" >> symfony/.env.test.local
echo "NEON_API_KEY=$NEON_API_KEY" >> symfony/.env.test.local
echo "NEON_PROJECT_ID=$NEON_PROJECT_ID" >> symfony/.env.test.local
mv gha-creds*.json symfony/google_credentials.json
docker compose exec -T php bash -c "composer install"
docker compose exec -T php bash -c "symfony console doctrine:schema:drop --full-database --force"
docker compose exec -T php bash -c "symfony console doctrine:migration:migrate --no-interaction"
docker compose exec -T php bash -c "symfony console app:remove-bucket ${{github.run_id}}--$GCLOUD_BUCKET_ID"
docker compose exec -T php bash -c "symfony console app:create-bucket ${{github.run_id}}--$GCLOUD_BUCKET_ID"
docker compose exec -T php bash -c "symfony console doctrine:fixtures:load --no-interaction"
docker compose exec -T php bash -c "npm install"
docker compose exec -T php bash -c "npm run build"
- name: lint
run: |
echo "lint with phpstan"
docker compose exec -T php bash -c "composer run phpstan"
echo "lint with eslint"
docker compose exec -T php bash -c "npm run lint"
- name: unit
run: docker compose exec -T php bash -c "symfony composer phpunit"
- name: e2e
env:
GCLOUD_PROJECT_ID: ${{secrets.GCLOUD_PROJECT_ID_TEST}}
GCLOUD_BUCKET_ID: ${{secrets.GCLOUD_BUCKET_ID_TEST}}
run: docker compose exec -T cypress bash -c "npm run cy:run"
- name: prepare deploy
if: steps.prepare.outputs.branch == 'main'
run: echo $HOSTS | base64 -d > deploy_hosts.php
env:
HOSTS: ${{secrets.HOSTS}}
- name: deploy
env:
HOSTS: ${{secrets.HOSTS}}
if: steps.prepare.outputs.branch == 'main'
uses: deployphp/action@v1
with:
dep: deploy
private-key: ${{ secrets.PRIVATE_KEY }}
verbosity: -vvv
deployer-version: "6.9.0"
- name: remove-bucket
run: docker compose exec -T php bash -c "symfony console app:remove-bucket ${{github.run_id}}--$GCLOUD_BUCKET_ID"
if: always()
env:
GCLOUD_BUCKET_ID: ${{secrets.GCLOUD_BUCKET_ID_TEST}}
- name: artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: artifacts
path: |
e2e/cypress/videos
e2e/cypress/screenshots