-
Notifications
You must be signed in to change notification settings - Fork 15
fix: Fix test workflow and add more platforms #34
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,12 @@ jobs: | |
| tests: | ||
| name: Unit & E2E | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| platform: [amd64, arm64, arm/v7, ppc64le] | ||
|
|
||
| env: | ||
| PLATFORM: ${{ matrix.platform == 'arm/v7' && 'armv7' || matrix.platform }} | ||
|
Comment on lines
+12
to
+13
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting an env for use by docker-compose
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should matrix platform just be
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The We could set it as
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. err ok, this is fine for now |
||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
|
|
@@ -14,19 +20,27 @@ jobs: | |
| submodules: recursive | ||
|
|
||
| - run: git checkout HEAD^2 | ||
|
|
||
| - name: Install dependencies | ||
| run: composer install --ignore-platform-reqs --no-interaction --prefer-dist | ||
|
Comment on lines
+24
to
+25
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Installing composer dependencies before is necessary because of how the container volumes are mounted by docker-compose |
||
|
|
||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
|
Comment on lines
+28
to
+30
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting up Qemu to run other platforms on an amd64 machine |
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
ChiragAgg5k marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Build image | ||
| - name: Build image for ${{ matrix.platform }} | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| context: . | ||
| push: false | ||
| tags: database-dev | ||
| tags: database-dev:${{ matrix.platform == 'arm/v7' && 'armv7' || matrix.platform }} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tags cannot have slashes so added a special check |
||
| load: true | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| platforms: linux/${{ matrix.platform }} | ||
|
Comment on lines
+34
to
+43
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conditionally spin up instances for specific architectures
ChiragAgg5k marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Start Containers | ||
| run: | | ||
|
|
@@ -35,9 +49,12 @@ jobs: | |
|
|
||
| - name: Run Tests | ||
| run: | | ||
| arch=$(uname -m) | ||
| if [ "${arch}" = "amd64" ]; then | ||
| if [[ "${{ matrix.platform }}" == "amd64" ]]; then | ||
| docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml --testsuite X86; | ||
| elif [ "${arch}" = "arm64" ] || [ "${arch}" = "aarch64" ]; then | ||
| docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml --testsuite ARM64; | ||
| elif [[ "${{ matrix.platform }}" == "arm64" ]]; then | ||
| docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml --testsuite ARM64; | ||
| elif [[ "${{ matrix.platform }}" == "arm/v7" ]]; then | ||
| docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml --testsuite ARMV7; | ||
| elif [[ "${{ matrix.platform }}" == "ppc64le" ]]; then | ||
| docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml --testsuite PPC; | ||
ChiragAgg5k marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ services: | |
| tests: | ||
| build: | ||
| context: . | ||
| image: database-dev:${PLATFORM} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Necessary to ensure docker always builds the container with the right architecture
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is PLATFORM set here? should there be a fallback?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. compose fetches PLATFORM from env variables, which are set in the workflow. No matter what strategy is running, an env var will aways be set, so the fallback is intrinsic. The same var is used as the tag while building the containers so the compose step will never fail
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if i run docker compose locally
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will have to set the env var and build the container with the correct tag. If you would prefer another approach, I can duplicate the compose and make one specifically for CI that is used in the CI and keep the default compose unchanged
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah either works, as long as we dont break local setup without extra steps |
||
| mem_limit: 512m | ||
| mem_reservation: 128M | ||
| cpus: 0.5 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added parallel running and more platforms to the workflow