diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 97ffad9e..8e0f3305 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -2,7 +2,7 @@ name : Setup, Build and Publish to Dev on: push: - branches: [xyz] + branches: [development] env: PROJECT_ID: ${{ secrets.GKE_PROJECT }} @@ -17,16 +17,11 @@ env: REPOSITORY_NAMESPACE: nfdi4chem jobs: - # php-unit-test: - # uses: NFDI4Chem/nmrxiv/.github/workflows/test.yml@development - - php-unit-test: - name: Run test + tests: + name: Run tests runs-on: ubuntu-latest - container: - image: kirschbaumdevelopment/laravel-test-runner:8.2 - - services: + + services: postgres: image: postgres:13 env: @@ -39,12 +34,18 @@ jobs: steps: - uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - fetch-depth: 1 + php-version: '8.2' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv + coverage: pcov - name: Install composer dependencies run: | composer install --ignore-platform-reqs + - name: Prepare Laravel Application run: | php -r "file_exists('.env') || copy('.env.ci.test', '.env');" @@ -63,91 +64,84 @@ jobs: - name: Install pcov run: | - apt-get update - apt-get -y install php-pcov + sudo apt-get update + sudo apt-get -y install php-pcov + - name: Install front-end dependencies run: | npm install npm run build - - name: Run Test - run: vendor/bin/phpunit tests/ --coverage-clover coverage.xml - #run: php artisan test --parallel --coverage coverage.xml + + - name: Run tests and collect coverage + run: vendor/bin/phpunit --coverage-clover coverage.xml - # Code coverage - # https://github.com/codecov/example-php/blob/main/.github/workflows/ci.yml - - name: Upload coverage reports to Codecov + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - # directory: ./coverage/reports/ - # fail_ci_if_error: true - # files: /home/runner/work/nmrxiv/nmrxiv/coverage.xml - # flags: unittests - # name: codecov-umbrella - # verbose: true - - # setup-build-publish-deploy: - # name: Build & deploy to development - # runs-on: ubuntu-latest - # needs: php-unit-test - # environment: - # name: Dev - # steps: - # # Checkout code - # - name: Checkout - # uses: actions/checkout@v4 - - # # Authenticate Github Actions to gcloud. - # - name: Authenticate GitHub Actions - # uses: 'google-github-actions/auth@v2' - # with: - # credentials_json: '${{ secrets.GKE_SA_KEY }}' - - # # Setup gcloud CLI - # - name: Setup gcloud CLI - # uses: google-github-actions/setup-gcloud@v2 - - # # Get the GKE credentials - # - name: Get GKE credentials - # uses: google-github-actions/get-gke-credentials@v2 - # with: - # cluster_name: ${{ env.GKE_CLUSTER }} - # location: ${{ env.GKE_ZONE }} - - # # Login to Docker - # - name: Log in to Docker Hub - # uses: docker/login-action@v3 - # with: - # username: ${{ env.DOCKER_HUB_USERNAME }} - # password: ${{ env.DOCKER_HUB_PASSWORD }} - - # # Build and push the app Docker image - # - name: Build and push App Docker image - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: ./resources/ops/docker/app/app.dockerfile - # push: true - # build-args: | - # RELEASE_VERSION=dev-app-latest - # tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-app-latest - - # # Build and push the nginx Docker image - # - name: Build and push Nginx Docker image - # uses: docker/build-push-action@v5 - # with: - # context: . - # file: ./resources/ops/docker/nginx/nginx.dockerfile - # push: true - # build-args: | - # RELEASE_VERSION=dev-nginx-latest - # tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-nginx-latest - - # # Deploy the latest Docker image to the GKE cluster - # - name: Deploy - # run: |- - # kubectl rollout restart deployment/$DEPLOYMENT_NAME - # kubectl rollout restart deployment/$WORKER_DEPLOYMENT_NAME - # kubectl rollout restart deployment/$SCHEDULER_DEPLOYMENT_NAME - # kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s - # kubectl get services -o wide \ No newline at end of file + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} + + setup-build-publish-deploy: + name: Build & deploy to development + runs-on: ubuntu-latest + needs: php-unit-test + environment: + name: Dev + steps: + # Checkout code + - name: Checkout + uses: actions/checkout@v4 + + # Authenticate Github Actions to gcloud. + - name: Authenticate GitHub Actions + uses: 'google-github-actions/auth@v2' + with: + credentials_json: '${{ secrets.GKE_SA_KEY }}' + + # Setup gcloud CLI + - name: Setup gcloud CLI + uses: google-github-actions/setup-gcloud@v2 + + # Get the GKE credentials + - name: Get GKE credentials + uses: google-github-actions/get-gke-credentials@v2 + with: + cluster_name: ${{ env.GKE_CLUSTER }} + location: ${{ env.GKE_ZONE }} + + # Login to Docker + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.DOCKER_HUB_USERNAME }} + password: ${{ env.DOCKER_HUB_PASSWORD }} + + # Build and push the app Docker image + - name: Build and push App Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./resources/ops/docker/app/app.dockerfile + push: true + build-args: | + RELEASE_VERSION=dev-app-latest + tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-app-latest + + # Build and push the nginx Docker image + - name: Build and push Nginx Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./resources/ops/docker/nginx/nginx.dockerfile + push: true + build-args: | + RELEASE_VERSION=dev-nginx-latest + tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-nginx-latest + + # Deploy the latest Docker image to the GKE cluster + - name: Deploy + run: |- + kubectl rollout restart deployment/$DEPLOYMENT_NAME + kubectl rollout restart deployment/$WORKER_DEPLOYMENT_NAME + kubectl rollout restart deployment/$SCHEDULER_DEPLOYMENT_NAME + kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s + kubectl get services -o wide \ No newline at end of file