|
| 1 | +name: test |
| 2 | +on: |
| 3 | + pull_request: ~ |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + name: test |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + install-args: ['', --prefer-lowest] |
| 15 | + php-version: ['7.2', '7.3', '7.4', '8.0'] |
| 16 | + steps: |
| 17 | + - name: cancel |
| 18 | + |
| 19 | + with: |
| 20 | + access_token: ${{ github.token }} |
| 21 | + |
| 22 | + - name: checkout |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: php |
| 26 | + uses: shivammathur/[email protected] |
| 27 | + with: |
| 28 | + php-version: ${{ matrix.php-version }} |
| 29 | + |
| 30 | + - name: composer-cache-dir |
| 31 | + id: composercache |
| 32 | + run: | |
| 33 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 34 | +
|
| 35 | + - name: composer-cache |
| 36 | + |
| 37 | + with: |
| 38 | + path: ${{ needs.prepare.outputs.composercachedir }} |
| 39 | + key: composer-${{ hashFiles('**/composer.lock') }} |
| 40 | + restore-keys: composer- |
| 41 | + |
| 42 | + - name: composer |
| 43 | + run: | |
| 44 | + composer check-platform-reqs --no-interaction |
| 45 | + composer update ${{ matrix.install-args }} --no-interaction --no-progress --prefer-dist |
| 46 | +
|
| 47 | + - name: phpunit |
| 48 | + run: | |
| 49 | + vendor/bin/phpunit |
| 50 | +
|
| 51 | + - name: phpstan-cache |
| 52 | + |
| 53 | + with: |
| 54 | + key: phpstan-${{ github.ref }}-${{ matrix.php-version }}-${{ matrix.install-args }}-${{ github.sha }} |
| 55 | + path: .phpstan-cache |
| 56 | + restore-keys: | |
| 57 | + phpstan-${{ github.ref }}-${{ matrix.php-version }}-${{ matrix.install-args }}-${{ github.sha }} |
| 58 | + phpstan-${{ github.ref }}-${{ matrix.php-version }}-${{ matrix.install-args }}- |
| 59 | + phpstan-${{ github.ref }}-${{ matrix.php-version }}- |
| 60 | + phpstan-${{ github.ref }}- |
| 61 | + phpstan- |
| 62 | +
|
| 63 | + - name: phpstan |
| 64 | + run: | |
| 65 | + mkdir -p .phpstan-cache |
| 66 | + APP_ENV=dev bin/console cache:clear |
| 67 | + vendor/bin/phpstan analyse --no-progress --no-interaction --memory-limit=1G |
| 68 | +
|
| 69 | + deploy: |
| 70 | + needs: [prepare, build, test] |
| 71 | + runs-on: ubuntu-latest |
| 72 | + steps: |
| 73 | + - name: checkout |
| 74 | + uses: actions/checkout@v2 |
| 75 | + |
| 76 | + - name: transcrypt |
| 77 | + run: | |
| 78 | + sudo curl -o /usr/local/bin/transcrypt https://raw.githubusercontent.com/elasticdog/transcrypt/master/transcrypt |
| 79 | + sudo chmod +x /usr/local/bin/transcrypt |
| 80 | +
|
| 81 | + transcrypt --yes -p '${{ secrets.TRANSCRYPT_PASSWORD }}' |
| 82 | +
|
| 83 | + - name: review |
| 84 | + if: ${{ github.ref != 'refs/heads/master' }} |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ github.token }} |
| 87 | + run: | |
| 88 | + echo "NAME_SUFFIX=-${{ github.event.pull_request.number }}" >> $GITHUB_ENV |
| 89 | + echo "HOSTNAME=review-${{ github.event.pull_request.number }}.holigral.app" >> $GITHUB_ENV |
| 90 | +
|
| 91 | + cat devops/secrets/.env.review >> $GITHUB_ENV |
| 92 | +
|
| 93 | + # Ugly |
| 94 | + BASE_URLS=() |
| 95 | + BASE_URLS_SLASHED=() |
| 96 | + for pr in $(hub pr list -f "%I%n") |
| 97 | + do |
| 98 | + BASE_URLS+=("https://review-$pr.holigral.app") |
| 99 | + BASE_URLS_SLASHED+=("https://review-$pr.holigral.app/") |
| 100 | + done |
| 101 | + BASE_URLS=$(printf ",%s" "${BASE_URLS[@]}") |
| 102 | + echo "BASE_URLS=[${BASE_URLS:1}]" >> $GITHUB_ENV |
| 103 | + BASE_URLS_SLASHED=$(printf ",%s" "${BASE_URLS_SLASHED[@]}") |
| 104 | + echo "BASE_URLS_SLASHED=[${BASE_URLS_SLASHED:1}]" >> $GITHUB_ENV |
| 105 | +
|
| 106 | + - name: staging |
| 107 | + if: ${{ github.ref == 'refs/heads/master' }} |
| 108 | + run: | |
| 109 | + cat devops/secrets/.env.staging >> $GITHUB_ENV |
| 110 | +
|
| 111 | + - name: node |
| 112 | + |
| 113 | + with: |
| 114 | + node-version: 16 |
| 115 | + |
| 116 | + - name: auth0-deploy |
| 117 | + env: |
| 118 | + AUTH0_ALLOW_DELETE: true |
| 119 | + BASE_URLS: ${{ env.BASE_URLS }} |
| 120 | + BASE_URLS_SLASHED: ${{ env.BASE_URLS_SLASHED }} |
| 121 | + AUTH0_CLIENT_ID: ${{ env.AUTH0_MGMT_CLIENT_ID }} |
| 122 | + AUTH0_CLIENT_SECRET: ${{ env.AUTH0_MGMT_CLIENT_SECRET }} |
| 123 | + run: | |
| 124 | + npx auth0-deploy-cli import -i devops/auth0/tenant.yaml |
| 125 | +
|
| 126 | + - name: regcred |
| 127 | + run: | |
| 128 | + export REGCRED="{\"auths\":{\"ghcr.io\":{\"username\":\"TamasSzigeti\",\"password\":\"${{ secrets.CR_PAT }}\",\"email\":\"[email protected]\",\"auth\":\"$(echo TamasSzigeti:${{ secrets.CR_PAT }} | base64)\"}}}" |
| 129 | + echo "REGCRED=$REGCRED" >> $GITHUB_ENV |
| 130 | +
|
| 131 | + - name: deploy |
| 132 | + env: |
| 133 | + SHA: ${{ needs.prepare.outputs.sha }} # Use prepare jobw |
| 134 | + run: | |
| 135 | + export KUBECONFIG=$(pwd)/devops/secrets/.kubeconfig |
| 136 | +
|
| 137 | + devops/kubernetes/deploy.sh |
| 138 | +
|
| 139 | + - name: status |
| 140 | + |
| 141 | + with: |
| 142 | + token: ${{ github.token }} |
| 143 | + environmentUrl: https://${{ env.HOSTNAME }} |
| 144 | + environment: ${{ env.ENVIRONMENT }} |
| 145 | + state: success |
| 146 | + |
| 147 | + - name: php |
| 148 | + uses: shivammathur/[email protected] |
| 149 | + with: |
| 150 | + php-version: '7.4' |
| 151 | + |
| 152 | + - name: composer-cache |
| 153 | + |
| 154 | + with: |
| 155 | + path: ${{ needs.prepare.outputs.composercachedir }} |
| 156 | + key: composer-${{ hashFiles('**/composer.lock') }} |
| 157 | + restore-keys: composer- |
| 158 | + |
| 159 | + - name: e2e |
| 160 | + env: |
| 161 | + PANTHER_EXTERNAL_BASE_URI: https://${{ env.HOSTNAME }} |
| 162 | + DATABASE_URL: postgres://hgapp:[email protected]:5432/hgapp |
| 163 | + run: | |
| 164 | + export KUBECONFIG=$(pwd)/devops/secrets/.kubeconfig |
| 165 | +
|
| 166 | + kubectl config set-context --current --namespace="hgapp-$ENVIRONMENT$NAME_SUFFIX" |
| 167 | +
|
| 168 | + kubectl port-forward service/postgres-pgpool 5432 & |
| 169 | +
|
| 170 | + composer install --no-interaction --no-progress --prefer-dist |
| 171 | + bin/phpunit --group ui |
0 commit comments