diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index 37bf5ee14..000000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Build & Release draft - -on: - push: - branches: - - 'master' - - 'prestashop/8.x' - pull_request: - types: [ opened, reopened, synchronize, edited ] - -env: - GCLOUD_TOKEN_PATH: ./token.json - -jobs: - deploy: - name: build dependencies & create artifact - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2.0.0 - - - name: Gcloud auth and write env file - run: | - echo $GOOGLE_APPLICATION_CREDENTIALS > $GCLOUD_TOKEN_PATH - gcloud auth activate-service-account --key-file=$GCLOUD_TOKEN_PATH - gcloud container clusters get-credentials $GCLOUD_CLUSTER \ - --zone europe-west1-c --project $GCLOUD_PROJECT - gcloud beta secrets versions access latest --project=$GCLOUD_PROJECT --secret="checkout-module" > .env - rm $GCLOUD_TOKEN_PATH - env: - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCLOUD_CREDENTIAL_PRODUCTION }} - GCLOUD_TOKEN_PATH: ${{ env.GCLOUD_TOKEN_PATH }} - GCLOUD_CLUSTER: ${{ secrets.GCLOUD_CLUSTER }} - GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT_PRODUCTION }} - - - name: Build JS dependencies - uses: PrestaShopCorp/github-action-build-js/12@v1.0 - with: - cmd: npm - path: ./ - - - name: Install composer dependencies - run: composer install --no-dev -o - - - name: Clean-up project - uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0 - - - name: Clean-up node_modules directory - run: sudo rm -rf node_modules - - - name: Create & upload artifact - uses: actions/upload-artifact@v1 - - with: - name: ${{ github.event.repository.name }} - path: ../ - update_release_draft: - runs-on: ubuntu-latest - needs: [deploy] - if: github.event_name == 'push' - steps: - - name: Download artifact - uses: actions/download-artifact@v1 - with: - name: ${{ github.event.repository.name }} - - id: release_info - uses: toolmantim/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Prepare for Release - run: | - cd ${{ github.event.repository.name }} - zip -r ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.zip ${{ github.event.repository.name }} -x '*.git*' - - name: Clean existing assets - shell: bash - run: | - curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 - assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'` - for asset in $assets - do - bin/hub api -X DELETE $asset - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to GitHub Release - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.release_info.outputs.upload_url }} - asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.zip - asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.zip - asset_content_type: application/zip diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 5ee41112c..baa866a4b 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -4,6 +4,7 @@ jobs: js-linter: name: JS linter runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'ready to review') steps: - name: Checkout uses: actions/checkout@v2.0.0 diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 8e90cf09e..4e7d80dca 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,8 +2,8 @@ name: PHP tests on: push: branches: - - 'master' - - 'prestashop/8.x' + - "master" + - "prestashop/8.x" pull_request: types: [opened, reopened, synchronize, edited] @@ -11,6 +11,7 @@ jobs: header-stamp: name: Check license headers runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'ready to review') steps: - name: Checkout uses: actions/checkout@v2 @@ -18,7 +19,7 @@ jobs: - name: Setup PHP 7.4 uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: "7.4" - name: Cache vendor folder uses: actions/cache@v1 @@ -36,9 +37,11 @@ jobs: - name: Run Header Stamp in Dry Run mode run: php vendor/bin/header-stamp --license=vendor/prestashop/header-stamp/assets/afl.txt --exclude=.github,node_modules,vendor,tests,_dev --dry-run + php-linter: name: PHP Syntax check 7.2|7.3|7.4 runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'ready to review') steps: - name: Checkout uses: actions/checkout@v2.0.0 @@ -48,20 +51,24 @@ jobs: uses: prestashop/github-action-php-lint/7.3@master - name: PHP syntax checker 7.4 uses: prestashop/github-action-php-lint/7.4@master + php-cs-fixer: name: PHP-CS-Fixer runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'ready to review') steps: - name: Checkout uses: actions/checkout@v2.0.0 - name: Run PHP-CS-Fixer uses: prestashopcorp/github-action-php-cs-fixer@master + phpstan: name: PHPStan runs-on: ubuntu-latest strategy: matrix: - presta-versions: ['8.0.0', 'latest'] + presta-versions: ["8.0.0", "latest"] + if: contains(github.event.pull_request.labels.*.name, 'ready to review') steps: - name: Checkout uses: actions/checkout@v2.0.0 @@ -83,11 +90,13 @@ jobs: - name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }}) run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }} - - name : Run PHPStan + - name: Run PHPStan run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module phpstan/phpstan:0.12 analyse --configuration=/web/module/tests/phpstan/phpstan-PS-8.neon --error-format github + phpunit: name: PHPUnit runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'ready to review') steps: - name: Checkout uses: actions/checkout@v2 @@ -95,7 +104,7 @@ jobs: - name: Setup PHP 7.4 uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: "7.4" - name: Cache vendor folder uses: actions/cache@v1 diff --git a/.github/workflows/ps8-build-release.yml b/.github/workflows/ps8-build-release.yml new file mode 100644 index 000000000..50522e972 --- /dev/null +++ b/.github/workflows/ps8-build-release.yml @@ -0,0 +1,200 @@ +name: PrestaShop 8 - Build & Release draft + +on: + pull_request: + types: [opened, reopened, synchronize, edited, labeled] + push: + tags: + - "v8.*" + branches: + - "prestashop/8.x" + +env: + ZIP_NAME_INTEGRATION: ${{ github.event.repository.name }}-integration-pr${{ github.event.number }} + ZIP_NAME_PREPRODUCTION: ${{ github.event.repository.name }}-preproduction-pr${{ github.event.number }} + ZIP_NAME_PRODUCTION: ${{ github.event.repository.name }}-${{ github.ref_name }} + +jobs: + deploy_integration: + name: INTEGRATION - Build dependencies & create artifact + runs-on: ubuntu-latest + if: + contains(github.event.pull_request.labels.*.name, 'integration deployment') && + contains(github.event.pull_request.labels.*.name, 'ps8') + + steps: + - name: Checkout the repository 🎁 + uses: actions/checkout@v4 + + - name: Auth GCP + uses: PrestaShopCorp/prestashop-github-action-gcp-auth@v1 + with: + auth-mode: "workload-federation" + provider: ${{ secrets.WI_PROVIDER_INTEGRATION }} + service-account: ${{ secrets.WI_SA_INTEGRATION }} + registry-login: true + + - name: Write .env file + run: gcloud beta secrets versions access latest --project=$GCP_PROJECT --secret="module-env" > .env + env: + GCP_PROJECT: ${{ secrets.GCP_PROJECT_INTEGRATION }} + + - name: Build JS dependencies + uses: PrestaShopCorp/github-action-build-js/12@v1.0 + with: + cmd: npm + path: ./ + + - name: Install composer dependencies + run: composer install --no-dev -o + + - name: Clean-up project + uses: PrestaShopCorp/github-action-clean-before-deploy@v2.0 + + - name: Clean-up node_modules directory + run: sudo rm -rf node_modules + + - name: Generate zip + run: | + cd ${{ github.event.repository.name }} + zip -r ${{ env.ZIP_NAME_INTEGRATION }}.zip ${{ github.event.repository.name }} -x '*.git*' + + - name: Push to GCP bucket storage + shell: bash + run: gsutil cp ${{ env.ZIP_NAME_INTEGRATION }}.zip gs://checkout-assets-integration/zips + + deploy_preproduction: + name: PREPRODUCTION - Build dependencies & create artifact + runs-on: ubuntu-latest + if: + contains(github.event.pull_request.labels.*.name, 'preproduction deployment') && + contains(github.event.pull_request.labels.*.name, 'ps8') + + steps: + - name: Checkout the repository 🎁 + uses: actions/checkout@v4 + + - name: Auth GCP + uses: PrestaShopCorp/prestashop-github-action-gcp-auth@v1 + with: + auth-mode: "workload-federation" + provider: ${{ secrets.WI_PROVIDER_PREPRODUCTION }} + service-account: ${{ secrets.WI_SA_PREPRODUCTION }} + registry-login: true + + - name: Write .env file + run: gcloud beta secrets versions access latest --project=$GCP_PROJECT --secret="module-env" > .env + env: + GCP_PROJECT: ${{ secrets.GCP_PROJECT_PREPRODUCTION }} + + - name: Build JS dependencies + uses: PrestaShopCorp/github-action-build-js/12@v1.0 + with: + cmd: npm + path: ./ + + - name: Install composer dependencies + run: composer install --no-dev -o + + - name: Clean-up project + uses: PrestaShopCorp/github-action-clean-before-deploy@v2.0 + + - name: Clean-up node_modules directory + run: sudo rm -rf node_modules + + - name: Generate zip + run: | + cd ${{ github.event.repository.name }} + zip -r ${{ env.ZIP_NAME_PREPRODUCTION }}.zip ${{ github.event.repository.name }} -x '*.git*' + + - name: Push to GCP bucket storage + shell: bash + run: gsutil cp ${{ env.ZIP_NAME_PREPRODUCTION }}.zip gs://checkout-assets-preproduction/zips + + deploy_production: + name: PRODUCTION - Build dependencies & create artifact + runs-on: ubuntu-latest + + steps: + - name: Checkout the repository 🎁 + uses: actions/checkout@v4 + + - name: Auth GCP + uses: PrestaShopCorp/prestashop-github-action-gcp-auth@v1 + with: + auth-mode: "workload-federation" + provider: ${{ secrets.WI_PROVIDER_PRODUCTION }} + service-account: ${{ secrets.WI_SA_PRODUCTION }} + registry-login: true + + - name: Write .env file + run: | + gcloud beta secrets versions access latest --project=$GCLOUD_PROJECT --secret="module-env" > .env + env: + GCLOUD_PROJECT: ${{ secrets.GCLOUD_PROJECT_PRODUCTION }} + + - name: Build JS dependencies + uses: PrestaShopCorp/github-action-build-js/12@v1.0 + with: + cmd: npm + path: ./ + + - name: Install composer dependencies + run: composer install --no-dev -o + + - name: Clean-up project + uses: PrestaShopCorp/github-action-clean-before-deploy@v2.0 + + - name: Clean-up node_modules directory + run: sudo rm -rf node_modules + + - name: Create & upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ZIP_NAME_PRODUCTION }} + path: ../ + + update_release_draft_production: + name: PRODUCTION - Update release draft + runs-on: ubuntu-latest + needs: [deploy_production] + if: github.event_name == 'push' + + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.ZIP_NAME_PRODUCTION }} + + - name: Release drafter + id: release_info + uses: toolmantim/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Prepare for Release + run: | + cd ${{ github.event.repository.name }} + zip -r ${{ env.ZIP_NAME_PRODUCTION }}.zip ${{ github.event.repository.name }} -x '*.git*' + + - name: Clean existing assets + shell: bash + run: | + curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 + assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'` + for asset in $assets + do + bin/hub api -X DELETE $asset + done + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to GitHub Release + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.release_info.outputs.upload_url }} + asset_path: ./${{ github.event.repository.name }}/${{ env.ZIP_NAME_PRODUCTION }}.zip + asset_name: ${{ env.ZIP_NAME_PRODUCTION }}.zip + asset_content_type: application/zip