From da50719e8d61f20c416ed856d26a66a97f0a0d68 Mon Sep 17 00:00:00 2001 From: Cenk Kucukiravul Date: Fri, 19 Jan 2024 15:21:32 +0100 Subject: [PATCH] [ECP-8825] Enable pipeline runs for external contributions (#2451) * Add e2e flow for external contributors * Add dispatch for debugging * Tweak workflow name * Tweak workflow * Debug * Remove draft pipeline * Update e2e test pipeline * Update GraphQL test pipeline * Update Main CI workflow * Update RestAPI test workflow * DEBUG - Add test pipeline * Add authorization step * DEBUG - Test auth step * Define an internal environment * DEBUG - Try removing auth step and switch to conditional * Remove trial pipeline * Add designated worklfow for debugging * Embed authorize step in build and add conditional * Remove debug pipeline --- .github/workflows/e2e-test.yml | 17 ++++--- .github/workflows/graphql-test.yml | 4 +- .github/workflows/main.yml | 76 +++++++++++++++--------------- .github/workflows/restapi-test.yml | 4 +- 4 files changed, 53 insertions(+), 48 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 8331abca6..968ede2ad 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -1,17 +1,16 @@ name: Magento 2 E2E Pipeline run-name: Adyen Magento 2 Payment Plugin E2E tests -on: +on: pull_request: - types: [opened, synchronize] + types: [opened, synchronize, ready_for_review] + pull_request_target: + types: [opened, synchronize, ready_for_review] jobs: build: - if: | - ${{ - github.event.pull_request.draft == false && - (github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]') - }} + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} runs-on: group: larger-runners labels: ubuntu-latest-8-cores @@ -43,7 +42,7 @@ jobs: - name: Install plugin run: docker exec -u www-data magento2-container make plugin - + - name: Kill Cron Jobs run: docker exec magento2-container /etc/init.d/cron stop @@ -51,7 +50,7 @@ jobs: uses: actions/checkout@v3 with: repository: Adyen/adyen-magento2-dev - ref: 'main' + ref: "main" token: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }} path: Developer diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml index 0486e3e4d..ef1627349 100644 --- a/.github/workflows/graphql-test.yml +++ b/.github/workflows/graphql-test.yml @@ -1,8 +1,10 @@ name: GraphQL Tests -on: [pull_request] +on: [pull_request, pull_request_target] jobs: build: + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} strategy: matrix: php-version: ["8.1"] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a844d5a96..272f8b25c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,47 +1,49 @@ name: Main CI workflow -on: [pull_request] +on: [pull_request, pull_request_target] jobs: build: + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} runs-on: ubuntu-latest - + strategy: matrix: php-version: [8.1] - + steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Use PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - tools: composer:v1 - - - name: Test plugin installation - run: | - echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json - composer install --prefer-dist - env: - CI: true - MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }} - MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }} - - - name: Code Sniffer - run: vendor/bin/phpcs --extensions=php,phtml --error-severity=10 --ignore-annotations - - - name: Run PHPUnit - run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit - - - name: Fix code coverage paths - run: sed -i "s;`pwd`/;;g" build/*.xml - - - name: SonarCloud Scan - if: ${{ env.SONAR_TOKEN }} - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Use PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v1 + + - name: Test plugin installation + run: | + echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json + composer install --prefer-dist + env: + CI: true + MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }} + MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }} + + - name: Code Sniffer + run: vendor/bin/phpcs --extensions=php,phtml --error-severity=10 --ignore-annotations + + - name: Run PHPUnit + run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit + + - name: Fix code coverage paths + run: sed -i "s;`pwd`/;;g" build/*.xml + + - name: SonarCloud Scan + if: ${{ env.SONAR_TOKEN }} + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/restapi-test.yml b/.github/workflows/restapi-test.yml index d7227b9b9..ba4607099 100644 --- a/.github/workflows/restapi-test.yml +++ b/.github/workflows/restapi-test.yml @@ -1,8 +1,10 @@ name: REST API Tests -on: [pull_request] +on: [pull_request, pull_request_target] jobs: build: + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} strategy: matrix: php-version: ["8.1"]