|
1 | 1 | name: Continuous Integration |
2 | 2 | on: |
3 | 3 | push: |
| 4 | + branches: |
| 5 | + - 'main' |
| 6 | + - 'master' |
| 7 | + - 'refs/heads/v[0-9]+.[0-9]+.[0-9]+' |
4 | 8 | pull_request: |
5 | 9 | jobs: |
6 | | - generate-checks-strategy: |
7 | | - name: Generate Checks |
| 10 | + package-name: |
| 11 | + name: Package Name |
8 | 12 | runs-on: ubuntu-latest |
| 13 | + needs: |
| 14 | + - lint-json |
| 15 | + outputs: |
| 16 | + package-name: ${{ steps.package-name.outputs.package-name }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v3 |
| 19 | + - id: package-name |
| 20 | + run: | |
| 21 | + printf "::set-output name=package-name::[\"%s\"]" $(docker run --rm -v "`pwd`:`pwd`" jess/jq jq -r -c '.name' "${GITHUB_WORKSPACE}/composer.json") |
| 22 | + supported-versions-matrix: |
| 23 | + name: Supported Versions Matrix |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: |
| 26 | + - lint-yaml |
| 27 | + - lint-json |
9 | 28 | outputs: |
10 | | - check: ${{ steps.generate-checks-strategy.outputs.check }} |
| 29 | + version: ${{ steps.supported-versions-matrix.outputs.version }} |
11 | 30 | steps: |
12 | | - - uses: actions/checkout@v1 |
13 | | - - id: generate-checks-strategy |
| 31 | + - uses: actions/checkout@v3 |
| 32 | + - id: supported-versions-matrix |
| 33 | + uses: WyriHaximus/github-action-composer-php-versions-in-range@v1 |
| 34 | + with: |
| 35 | + upcomingReleases: true |
| 36 | + supported-checks-matrix: |
| 37 | + name: Supported Checks Matrix |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: |
| 40 | + - lint-yaml |
| 41 | + outputs: |
| 42 | + check: ${{ steps.supported-checks-matrix.outputs.check }} |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v3 |
| 45 | + - id: supported-checks-matrix |
14 | 46 | name: Generate check |
15 | 47 | run: | |
16 | 48 | printf "Checks found: %s\r\n" $(make task-list-ci) |
17 | 49 | printf "::set-output name=check::%s" $(make task-list-ci) |
18 | | - lint: |
19 | | - runs-on: ubuntu-latest |
20 | | - steps: |
21 | | - - name: Lint Code Base |
22 | | - uses: docker://github/super-linter:v2.2.0 |
23 | | - composer-install: |
| 50 | + can-require: |
| 51 | + name: Test we can require "${{ matrix.package-name }}" on PHP ${{ matrix.php }} |
24 | 52 | strategy: |
25 | 53 | fail-fast: false |
26 | 54 | matrix: |
27 | | - php: [7.4, "8.0", 8.1] |
28 | | - composer: [lowest, current, highest] |
29 | | - needs: lint |
| 55 | + php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }} |
| 56 | + package-name: ${{ fromJson(needs.package-name.outputs.package-name) }} |
| 57 | + needs: |
| 58 | + - lint-yaml |
| 59 | + - lint-json |
| 60 | + - package-name |
| 61 | + - supported-versions-matrix |
30 | 62 | runs-on: ubuntu-latest |
31 | 63 | container: |
32 | | - image: wyrihaximusnet/php:${{ matrix.php }}-nts-alpine-slim-dev-root |
| 64 | + image: ghcr.io/wyrihaximusnet/php:${{ matrix.php }}-nts-buster-dev-root |
33 | 65 | steps: |
34 | | - - uses: actions/checkout@v1 |
35 | | - - name: Cache composer packages |
36 | | - uses: actions/cache@v1 |
| 66 | + - uses: actions/checkout@v3 |
37 | 67 | with: |
38 | | - path: ./vendor/ |
39 | | - key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }} |
40 | | - - name: Install Dependencies |
41 | | - run: composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o |
42 | | - if: matrix.composer == 'lowest' |
43 | | - - name: Install Dependencies |
44 | | - run: composer install --ansi --no-progress --no-interaction --prefer-dist -o |
45 | | - if: matrix.composer == 'current' |
46 | | - - name: Install Dependencies |
47 | | - run: composer update --ansi --no-progress --no-interaction --prefer-dist -o |
48 | | - if: matrix.composer == 'highest' |
| 68 | + path: checked_out_package |
| 69 | + - name: Set Up composer.json |
| 70 | + run: | |
| 71 | + echo "{\"repositories\": [{\"name\": \"${{ matrix.package-name }}\",\"type\": \"path\",\"url\": \"./checked_out_package\"}]}" > composer.json |
| 72 | + - name: Require package |
| 73 | + run: | |
| 74 | + composer require "${{ matrix.package-name }}:dev-${GITHUB_SHA}" --no-progress --ansi --no-interaction --prefer-dist -o -vvv || composer require "${{ matrix.package-name }}:dev-${GITHUB_REF_NAME}" --no-progress --ansi --no-interaction --prefer-dist -o -vvv |
49 | 75 | qa: |
| 76 | + name: Run ${{ matrix.check }} on PHP ${{ matrix.php }} with ${{ matrix.composer }} dependency preference |
50 | 77 | strategy: |
51 | 78 | fail-fast: false |
52 | 79 | matrix: |
53 | | - php: [7.4, "8.0", 8.1] |
54 | | - composer: [lowest, current, highest] |
55 | | - check: ${{ fromJson(needs.generate-checks-strategy.outputs.check) }} |
| 80 | + php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }} |
| 81 | + composer: [lowest, locked, highest] |
| 82 | + check: ${{ fromJson(needs.supported-checks-matrix.outputs.check) }} |
56 | 83 | needs: |
57 | | - - composer-install |
58 | | - - generate-checks-strategy |
| 84 | + - lint-yaml |
| 85 | + - lint-json |
| 86 | + - supported-checks-matrix |
| 87 | + - supported-versions-matrix |
59 | 88 | runs-on: ubuntu-latest |
60 | 89 | container: |
61 | | - image: wyrihaximusnet/php:${{ matrix.php }}-nts-alpine-slim-dev-root |
| 90 | + image: ghcr.io/wyrihaximusnet/php:${{ matrix.php }}-nts-buster-dev-root |
62 | 91 | steps: |
63 | | - - uses: actions/checkout@v1 |
64 | | - - name: Cache composer packages |
65 | | - uses: actions/cache@v1 |
| 92 | + - uses: actions/checkout@v3 |
| 93 | + - uses: ramsey/composer-install@v2 |
66 | 94 | with: |
67 | | - path: ./vendor/ |
68 | | - key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }} |
69 | | - - name: Install Dependencies |
70 | | - run: (test -f vendor && true ) || composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o |
71 | | - if: matrix.composer == 'lowest' |
72 | | - - name: Install Dependencies |
73 | | - run: (test -f vendor && true ) || composer install --ansi --no-progress --no-interaction --prefer-dist -o |
74 | | - if: matrix.composer == 'current' |
75 | | - - name: Install Dependencies |
76 | | - run: (test -f vendor && true ) || composer update --ansi --no-progress --no-interaction --prefer-dist -o |
77 | | - if: matrix.composer == 'highest' |
| 95 | + dependency-versions: ${{ matrix.composer }} |
78 | 96 | - name: Fetch Tags |
79 | | - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 97 | + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true |
80 | 98 | if: matrix.check == 'backward-compatibility-check' |
81 | 99 | - run: make ${{ matrix.check }} |
| 100 | + env: |
| 101 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 102 | + COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }} |
| 103 | + tests-directly-on-os: |
| 104 | + name: Run tests on PHP ${{ matrix.php }} with ${{ matrix.composer }} dependency preference (${{ matrix.os }}) |
| 105 | + strategy: |
| 106 | + fail-fast: false |
| 107 | + matrix: |
| 108 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 109 | + php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }} |
| 110 | + composer: [lowest, locked, highest] |
| 111 | + needs: |
| 112 | + - lint-yaml |
| 113 | + - lint-json |
| 114 | + - supported-checks-matrix |
| 115 | + - supported-versions-matrix |
| 116 | + runs-on: ${{ matrix.os }} |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v3 |
| 119 | + - uses: shivammathur/setup-php@v2 |
| 120 | + with: |
| 121 | + php-version: ${{ matrix.php }} |
| 122 | + coverage: pcov |
| 123 | + extensions: intl, sodium |
| 124 | + - uses: ramsey/composer-install@v2 |
| 125 | + with: |
| 126 | + dependency-versions: ${{ matrix.composer }} |
| 127 | + - run: | |
| 128 | + make unit-testing-raw |
| 129 | + env: |
| 130 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} |
| 131 | + COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }} |
| 132 | + lint-yaml: |
| 133 | + name: Lint YAML |
| 134 | + runs-on: ubuntu-latest |
| 135 | + steps: |
| 136 | + - uses: actions/checkout@v3 |
| 137 | + - name: yaml-lint |
| 138 | + uses: ibiqlik/action-yamllint@v3 |
| 139 | + with: |
| 140 | + config_data: | |
| 141 | + extends: default |
| 142 | + ignore: | |
| 143 | + /.git/ |
| 144 | + rules: |
| 145 | + line-length: disable |
| 146 | + document-start: disable |
| 147 | + truthy: disable |
| 148 | + lint-json: |
| 149 | + name: Lint JSON |
| 150 | + runs-on: ubuntu-latest |
| 151 | + steps: |
| 152 | + - uses: actions/checkout@v3 |
| 153 | + - name: json-syntax-check |
| 154 | + uses: limitusus/json-syntax-check@v1 |
| 155 | + with: |
| 156 | + pattern: "\\.json$" |
| 157 | + check-mark: |
| 158 | + name: ✔️ |
| 159 | + needs: |
| 160 | + - lint-yaml |
| 161 | + - lint-json |
| 162 | + - can-require |
| 163 | + - qa |
| 164 | + - tests-directly-on-os |
| 165 | + runs-on: ubuntu-latest |
| 166 | + steps: |
| 167 | + - run: echo "✔️" |
0 commit comments