-
Notifications
You must be signed in to change notification settings - Fork 15
Nx Integration Tests Github Workflow #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1fd928e
dev: work on nx integration github workflow
adamzero1 7af06fc
dev: removing debug
adamzero1 28524a8
dev: removing examples of other jobs
adamzero1 a85b811
dev: implementing suggested changes
adamzero1 5bf3436
dev: using range for Nx version
adamzero1 6632e42
dev: using range for Nx version
adamzero1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| name: NX Integration Test | ||
| #description: Workflow to run NX assisted integration tests for Mage-OS projects. | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| repository: | ||
| type: string | ||
| description: "Repository" | ||
| required: true | ||
| pr_head: | ||
| type: string | ||
| description: "head SHA" | ||
| required: true | ||
| pr_base: | ||
| type: string | ||
| description: "pr base SHA" | ||
| required: true | ||
| workflow_dispatch: | ||
| inputs: | ||
| repository: | ||
| type: string | ||
| description: "Repository" | ||
| required: true | ||
| pr_head: | ||
| type: string | ||
| description: "head SHA" | ||
| required: true | ||
| pr_base: | ||
| type: string | ||
| description: "pr base SHA" | ||
| required: true | ||
|
|
||
| jobs: | ||
| debug: | ||
| name: Debug | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: debug | ||
| shell: bash | ||
| env: | ||
| repository: ${{ inputs.repository }} | ||
| pr_head: ${{ inputs.pr_head }} | ||
| pr_base: ${{ inputs.pr_base }} | ||
| run: | | ||
| echo "input was" | ||
| echo "repository: ${repository}" | ||
| echo "pr_head: ${pr_head}" | ||
| echo "pr_base: ${pr_base}" | ||
|
|
||
| matrix-calculator: | ||
| outputs: | ||
| php_versions: ${{ steps.calculate-matrix.outputs.php_versions }} | ||
| database_versions: ${{ steps.calculate-matrix.outputs.database_versions }} | ||
| search_versions: ${{ steps.calculate-matrix.outputs.search_versions }} | ||
| message_queue_versions: ${{ steps.calculate-matrix.outputs.message_queue_versions }} | ||
| cache_versions: ${{ steps.calculate-matrix.outputs.cache_versions }} | ||
| http_cache_versions: ${{ steps.calculate-matrix.outputs.http_cache_versions }} | ||
|
|
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Run Matrix Calulator | ||
| id: calculate-matrix | ||
| uses: mage-os/github-actions/supported-services-matrix-calculator@main | ||
| with: | ||
| repository: ${{ inputs.repository }} | ||
| ref: ${{ inputs.pr_head }} | ||
|
|
||
| - name: Calculated Result | ||
| shell: bash | ||
| env: | ||
| php_versions: ${{ steps.calculate-matrix.outputs.php_versions }} | ||
| database_versions: ${{ steps.calculate-matrix.outputs.database_versions }} | ||
| search_versions: ${{ steps.calculate-matrix.outputs.search_versions }} | ||
| message_queue_versions: ${{ steps.calculate-matrix.outputs.message_queue_versions }} | ||
| cache_versions: ${{ steps.calculate-matrix.outputs.cache_versions }} | ||
| http_cache_versions: ${{ steps.calculate-matrix.outputs.http_cache_versions }} | ||
| run: | | ||
| echo "PHP Versions: $php_versions" | ||
| echo "database_versions: $database_versions" | ||
| echo "search_versions: $search_versions" | ||
| echo "message_queue_versions: $message_queue_versions" | ||
| echo "cache_versions: $cache_versions" | ||
| echo "http_cache_versions: $http_cache_versions" | ||
|
|
||
| nx-project-setup: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Run Nx Project Setup | ||
| uses: mage-os/github-actions/nx-integration-tests-setup@main | ||
| with: | ||
| repository: ${{ inputs.repository }} | ||
| ref: ${{ inputs.pr_head }} | ||
| pr_base: ${{ inputs.pr_base }} | ||
|
|
||
| integration-tests: | ||
| needs: | ||
| - matrix-calculator | ||
| - nx-project-setup | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php_version: ${{ fromJSON(needs.matrix-calculator.outputs.php_versions) }} | ||
| database_version: ${{ fromJSON(needs.matrix-calculator.outputs.database_versions) }} | ||
| search_version: ${{ fromJSON(needs.matrix-calculator.outputs.search_versions) }} | ||
| message_queue_version: ${{ fromJSON(needs.matrix-calculator.outputs.message_queue_versions) }} | ||
| cache_version: ${{ fromJSON(needs.matrix-calculator.outputs.cache_versions) }} | ||
| http_cache_version: ${{ fromJSON(needs.matrix-calculator.outputs.http_cache_versions) }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Project Cache | ||
| uses: actions/cache/restore@v3 | ||
| with: | ||
| path: main | ||
| key: ${{ runner.os }}-project-${{ inputs.ref }} | ||
|
|
||
| # could probably swap this to a docker container in future | ||
| - name: Install NX | ||
| working-directory: ./main | ||
| run: | | ||
| npm install -g nx@^15.4 | ||
|
|
||
| - name: Print Affected | ||
| working-directory: ./main | ||
| run: | | ||
| AFFECTED_OUTPUT=/tmp/affect.json | ||
| nx print-affected --head=HEAD --base=remotes/origin/${{ inputs.pr_base }} > ${AFFECTED_OUTPUT} | ||
| cat ${AFFECTED_OUTPUT} | ||
| echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})" | ||
|
|
||
| - name: Setup Warden Environment | ||
| uses: mage-os/github-actions/warden/setup-environment@main | ||
| with: | ||
| php_version: ${{ matrix.php_version }} | ||
| database: ${{ matrix.database_version }} | ||
| search: ${{ matrix.search_version }} | ||
| rabbitmq: ${{ matrix.message_queue_version }} | ||
| redis: ${{ matrix.cache_version }} | ||
| varnish: ${{ matrix.http_cache_version }} | ||
| base_directory: "./main" | ||
|
|
||
| - name: Setup config for Integration tests | ||
| uses: mage-os/github-actions/warden/integration-tests@main | ||
| with: | ||
| search: ${{ matrix.search_version }} | ||
| rabbitmq: ${{ matrix.message_queue_version }} | ||
| redis: ${{ matrix.cache_version }} | ||
| run_memory_test: 0 | ||
| run_magento_integration_tests: 0 | ||
| run_magento_integration_tests_real_suite: 0 | ||
| base_directory: "./main" | ||
|
|
||
| - name: Run Integration Tests (Real) | ||
| working-directory: ./main | ||
| run: | | ||
| export WARDEN="$(dirname $(pwd))/warden/bin/warden" | ||
| nx affected --target=test:integration --head=HEAD --base=remotes/origin/${{ inputs.pr_base }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: "Nx Integration Tests Setup" | ||
| author: "Mage-OS" | ||
| description: "Setup and cache Nx project, this can then be reused with all service combinations." | ||
|
|
||
| inputs: | ||
| repository: | ||
| type: string | ||
| description: "Repository" | ||
| required: true | ||
| ref: | ||
| type: string | ||
| description: "head SHA" | ||
| required: true | ||
| pr_base: | ||
| type: string | ||
| description: "pr base SHA" | ||
| required: true | ||
|
|
||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Checkout PR commit | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: ${{ inputs.repository }} | ||
| ref: ${{ inputs.ref }} | ||
| path: main | ||
| # Need to do this otherwise Nx cant determine diff | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Fetch base | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: git fetch origin ${{ inputs.pr_base }} | ||
|
|
||
| - name: Cache Composer dependencies | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: /tmp/composer-cache | ||
| key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} | ||
|
|
||
| - id: get-composer-and-php-version | ||
| name: Get Composer & PHP Version | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| echo "php_version=$(jq -c .services.php[0] supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| echo "composer_version=$(jq -rc .services.composer[0] supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| - name: Composer Install | ||
| uses: php-actions/composer@v6 | ||
| with: | ||
| version: ${{ steps.get-composer-and-php-version.outputs.composer_version }} | ||
| php_version: ${{ steps.get-composer-and-php-version.outputs.php_version }} | ||
| args: "--ignore-platform-reqs --optimize-autoloader" | ||
| working_dir: main | ||
|
|
||
| # could probably swap this to a docker container in future | ||
| - name: Install NX | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| npm install -g nx@^15.4 | ||
|
|
||
| # should be able to cache this in future also | ||
| - name: Checkout Nx Repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: adamzero1/nx-for-php | ||
|
sprankhub marked this conversation as resolved.
|
||
| ref: docker-wrapper-2 | ||
| path: nx | ||
|
|
||
| - name: Copy in NX files | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| NXDIR="../nx" | ||
| cp -r ${NXDIR}/nx ./ | ||
| cp ${NXDIR}/nx.json ./ | ||
| cp ${NXDIR}/package.json ./ | ||
| cp ${NXDIR}/package-lock.json ./ | ||
|
|
||
| - name: Install NPM Deps | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| npm ci | ||
|
|
||
| - name: Generate Nx Workspace | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| npm run generate-workspace -- --commands=test:unit,test:integration \ | ||
| --test:unit='if [ -d {{ MODULE_PATH }}Test/Unit ]; then ${WARDEN} env exec -T php-fpm ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml {{ MODULE_PATH }}Test/Unit; else echo "{{ MODULE_NAME }} has no unit test; fi' \ | ||
| --test:integration='${WARDEN} env exec -T --workdir /var/www/html/dev/tests/integration php-fpm ../../../vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite '"'"'Magento Integration Tests Real Suite'"'"' --filter='"'"'/Magento/{{ MODULE_DIRECTORY }}/|Magento\\{{ MODULE_DIRECTORY }}'"'"' --log-junit=../../../phpunit-output/junit/{{ MODULE_DIRECTORY }}.xml --coverage-html=../../../phpunit-output/coverage-html/{{ MODULE_DIRECTORY }}' | ||
|
|
||
| - name: Print Affected | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| AFFECTED_OUTPUT=/tmp/affect.json | ||
| nx print-affected --head=HEAD --base=remotes/origin/${{ inputs.pr_base }} > ${AFFECTED_OUTPUT} | ||
| echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})" | ||
|
|
||
| # just to get some timings | ||
| - name: Print Affected2 | ||
| working-directory: ./main | ||
| shell: bash | ||
| run: | | ||
| AFFECTED_OUTPUT=/tmp/affect.json | ||
| nx print-affected --head=HEAD --base=remotes/origin/${{ inputs.pr_base }} > ${AFFECTED_OUTPUT} | ||
| echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})" | ||
|
|
||
| - name: Project Cache | ||
| uses: actions/cache/save@v3 | ||
| with: | ||
| path: main | ||
| key: ${{ runner.os }}-project-${{ inputs.ref }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: "Supported Services Matrix Calculator" | ||
| author: "Mage-OS" | ||
| description: "Calulate a matrix of all supported services (based off supported-services.json)" | ||
|
|
||
| inputs: | ||
| repository: | ||
| type: string | ||
| description: "Repository" | ||
| required: true | ||
| ref: | ||
| type: string | ||
| description: "head SHA" | ||
| required: true | ||
|
|
||
| outputs: | ||
| php_versions: | ||
| description: The applicable PHP versions | ||
| value: ${{ steps.set-matrix.outputs.php_versions }} | ||
| database_versions: | ||
| description: The applicable DB versions | ||
| value: ${{ steps.set-matrix.outputs.database_versions }} | ||
| search_versions: | ||
| description: The applicable Search versions | ||
| value: ${{ steps.set-matrix.outputs.search_versions }} | ||
| message_queue_versions: | ||
| description: The applicable Message Queue versions | ||
| value: ${{ steps.set-matrix.outputs.message_queue_versions }} | ||
| cache_versions: | ||
| description: The applicable Cache versions | ||
| value: ${{ steps.set-matrix.outputs.cache_versions }} | ||
| http_cache_versions: | ||
| description: The applicable HTTP Cache versions | ||
| value: ${{ steps.set-matrix.outputs.http_cache_versions }} | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Checkout PR commit | ||
| uses: actions/checkout@v3 | ||
|
adamzero1 marked this conversation as resolved.
|
||
| with: | ||
| repository: ${{ inputs.repository }} | ||
| ref: ${{ inputs.ref }} | ||
|
|
||
| - id: set-matrix | ||
| name: Calculate Matrix | ||
| shell: bash | ||
| run: | | ||
| echo "php_versions=$(jq -c .services.php supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| echo "database_versions=$(jq -c .services.database supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| echo "search_versions=$(jq -c .services.search supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| echo "message_queue_versions=$(jq -c .services.message_queue supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| echo "cache_versions=$(jq -c .services.cache supported-services.json)" >> "$GITHUB_OUTPUT" | ||
| echo "http_cache_versions=$(jq -c .services.http_cache supported-services.json)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Debug output | ||
| shell: bash | ||
| run: | | ||
| echo "PHP Versions: ${{ steps.set-matrix.outputs.php_versions }}" | ||
| echo "database Versions: ${{ steps.set-matrix.outputs.database_versions }}" | ||
| echo "search Versions: ${{ steps.set-matrix.outputs.search_versions }}" | ||
| echo "message_queue Versions: ${{ steps.set-matrix.outputs.message_queue_versions }}" | ||
| echo "cache Versions: ${{ steps.set-matrix.outputs.cache_versions }}" | ||
| echo "http_cache Versions: ${{ steps.set-matrix.outputs.http_cache_versions }}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.