|
| 1 | +name: "Installation Test" |
| 2 | +author: "Graycore" |
| 3 | +description: " A Github Action that tests the installability of a Magento Package" |
| 4 | + |
| 5 | +inputs: |
| 6 | + php_version: |
| 7 | + required: true |
| 8 | + default: "8.1" |
| 9 | + description: "PHP Version to use" |
| 10 | + |
| 11 | + cache_key: |
| 12 | + required: true |
| 13 | + default: "2" |
| 14 | + description: "The cache key used to hold Composer Packages" |
| 15 | + |
| 16 | + composer_version: |
| 17 | + required: true |
| 18 | + default: "2" |
| 19 | + description: "The version of composer to use" |
| 20 | + |
| 21 | + source_folder: |
| 22 | + required: true |
| 23 | + default: $GITHUB_WORKSPACE |
| 24 | + description: "The source folder of the package" |
| 25 | + |
| 26 | + package_name: |
| 27 | + required: true |
| 28 | + description: "The name of the package" |
| 29 | + |
| 30 | + magento_directory: |
| 31 | + required: true |
| 32 | + default: "../magento2" |
| 33 | + description: "The folder where Magento will be installed" |
| 34 | + |
| 35 | + magento_version: |
| 36 | + required: true |
| 37 | + default: "magento/project-community-edition" |
| 38 | + description: "The version of Magento to test against" |
| 39 | + |
| 40 | + magento_repository: |
| 41 | + required: true |
| 42 | + default: "https://repo.magento.com/" |
| 43 | + description: "Where to install Magento from" |
| 44 | + |
| 45 | + composer_auth: |
| 46 | + required: true |
| 47 | + description: "Composer Authentication Credentials" |
| 48 | + |
| 49 | +runs: |
| 50 | + using: "composite" |
| 51 | + steps: |
| 52 | + - name: Set PHP Version |
| 53 | + uses: shivammathur/setup-php@v2 |
| 54 | + with: |
| 55 | + php-version: ${{ inputs.php_version }} |
| 56 | + |
| 57 | + - run: composer self-update --${{ inputs.composer_version }} |
| 58 | + name: Pin to Composer Version ${{ inputs.composer_version }} |
| 59 | + shell: bash |
| 60 | + |
| 61 | + - run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ inputs.magento_version }}" ${{ inputs.magento_directory }} --no-install |
| 62 | + shell: bash |
| 63 | + env: |
| 64 | + COMPOSER_AUTH: ${{ inputs.composer_auth }} |
| 65 | + name: Create Magento ${{ inputs.magento_version }} Project |
| 66 | + |
| 67 | + - name: Get Composer Cache Directory |
| 68 | + shell: bash |
| 69 | + working-directory: ${{ inputs.magento_directory }} |
| 70 | + id: composer-cache |
| 71 | + run: | |
| 72 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 73 | +
|
| 74 | + - name: "Cache Composer Packages" |
| 75 | + uses: actions/cache@v3 |
| 76 | + with: |
| 77 | + key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ inputs.composer_version }} | ${{ inputs.php_version }} | ${{ inputs.magento_version }}' |
| 78 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 79 | + |
| 80 | + - run: composer config repositories.local path ${{ inputs.source_folder }} |
| 81 | + name: Add Github Repo for Testing |
| 82 | + working-directory: ${{ inputs.magento_directory }} |
| 83 | + shell: bash |
| 84 | + |
| 85 | + - run: composer require ${{ inputs.package_name }} "@dev" --no-update && composer install |
| 86 | + name: Require and attempt install |
| 87 | + working-directory: ${{ inputs.magento_directory }} |
| 88 | + shell: bash |
| 89 | + env: |
| 90 | + COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }} |
| 91 | + COMPOSER_AUTH: ${{ inputs.composer_auth }} |
| 92 | + |
| 93 | +branding: |
| 94 | + icon: "code" |
| 95 | + color: "green" |
0 commit comments