diff --git a/.codepipeline/docker/setup.sh b/.codepipeline/docker/setup.sh index c25423d..8603886 100755 --- a/.codepipeline/docker/setup.sh +++ b/.codepipeline/docker/setup.sh @@ -74,7 +74,7 @@ fi # System dir and composer packages must exist if [ ! -f "/var/www/html/system/web.php" ] || [ ! -f "/var/www/html/composer.json" ] || [ -n "$CMFIVE_CORE_BRANCH" ]; then - CMFIVE_CORE_BRANCH=${CMFIVE_CORE_BRANCH:-master} # Default to master if not set + CMFIVE_CORE_BRANCH=${CMFIVE_CORE_BRANCH:-main} # Default to main if not set rm -rf /var/www/html/system # Remove system dir to ensure correct core is installed echo "➕ Installing core from branch [ $CMFIVE_CORE_BRANCH ]" php cmfive.php install core $CMFIVE_CORE_BRANCH @@ -92,7 +92,7 @@ php cmfive.php install migrations if [ "$ENVIRONMENT" = "development" ]; then echo "🧑‍💻 Development mode" echo "Creating admin user" - php cmfive.php seed admin Admin Admin dev@2pisoftware.com admin admin + php cmfive.php seed admin admin admin dev@2pisoftware.com admin admin fi #Let container know that everything is finished diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 94858a9..ec8b534 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,9 +4,13 @@ on: pull_request: branches: - develop + - master push: + tags: + - 'v*' branches: - develop + - master jobs: build-and-publish: @@ -21,6 +25,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: @@ -38,6 +45,7 @@ jobs: type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} labels: | org.opencontainers.image.title=Cmfive org.opencontainers.image.description=Cmfive in a docker image @@ -51,9 +59,24 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # Build and push the image - - name: Build and push cmfive image - uses: docker/build-push-action@v5 + # Build combined ARM/x86-64 image on master and develop branches + - name: Build and push cmfive ARM/x86-64 image + uses: docker/build-push-action@v6 + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/v') + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/2pisoftware/cmfive:buildcache + cache-to: type=registry,ref=ghcr.io/2pisoftware/cmfive:buildcache,mode=max + # x86-64 and ARM64 + platforms: linux/amd64,linux/arm64 + + # Build x86-64 image on other branches + - name: Build and push cmfive x86-64 image + uses: docker/build-push-action@v6 + if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop' && !startsWith(github.ref, 'refs/tags/v') with: context: . push: true @@ -61,10 +84,14 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/2pisoftware/cmfive:buildcache cache-to: type=registry,ref=ghcr.io/2pisoftware/cmfive:buildcache,mode=max + # x86-64 + platforms: linux/amd64 # Scan the docker image and compare it with the latest image - name: Docker Scout uses: docker/scout-action@v1 + # only on pull requests + if: github.event_name == 'pull_request' with: command: compare,cves image: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index e8748d0..8cacf4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,11 +24,13 @@ RUN apk --no-cache add \ git # Clone github.com/2pisoftware/cmfive-core -ARG CORE_BRANCH=master +ARG CORE_BRANCH=main RUN git clone --depth 1 https://github.com/2pisoftware/cmfive-core.git -b $CORE_BRANCH # Compile the theme -RUN cd /cmfive-core/system/templates/base && npm install && npm run production +RUN cd /cmfive-core/system/templates/base && \ + npm ci && \ + npm run production # -------------------------------------------------------------------------- # == Cmfive stage == @@ -126,6 +128,12 @@ COPY --chown=cmfive:cmfive \ --from=core \ /cmfive-core/system/templates/base/dist \ system/templates/base/dist + +# Copy theme node modules +COPY --chown=cmfive:cmfive \ + --from=core \ + /cmfive-core/system/templates/base/node_modules \ + system/templates/base/node_modules # Fix permissions RUN chmod -R ugo=rwX cache/ storage/ uploads/ && \ diff --git a/README.md b/README.md index b7bd03f..e7913b8 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ The following options can be used with the Docker image. You may choose to use f The following build args can be used to customise the Docker image if you are building a custom one: -- **CORE_BRANCH:** The branch of the cmfive-core repository to bake in at build-time. Defaults to `master`. +- **CORE_BRANCH:** The branch of the cmfive-core repository to bake in at build-time. Defaults to `main`. - **PHP_VERSION:** The version of PHP to use. See alpine linux packages for available versions. Defaults to the version in the Dockerfile (eg 81). #### Volumes diff --git a/cmfive.php b/cmfive.php index 89c04d9..d9762db 100755 --- a/cmfive.php +++ b/cmfive.php @@ -44,7 +44,7 @@ $menuMaker = [ [ - 'option' => "Install core libraries", 'message' => "Installing core libraries", 'function' => "installCoreLibraries", 'param' => "master" + 'option' => "Install core libraries", 'message' => "Installing core libraries", 'function' => "installCoreLibraries", 'param' => "main" ], [ 'option' => "Install database migrations", 'message' => "Installing migrations", 'function' => "installMigrations", 'param' => null @@ -61,7 +61,7 @@ 'install' => [ [ 'request' => "core", 'message' => "Installing core libraries", 'function' => "cmdinstallCoreLibraries", 'args' => true, - 'hint' => "cmfive-core reference (default is 'master')", "default" => ['branch' => "master"] + 'hint' => "cmfive-core reference (default is 'main')", "default" => ['branch' => "main"] ], [ 'request' => "migration", 'message' => "Installing migrations", 'function' => "installMigrations", 'args' => false @@ -270,7 +270,7 @@ function installCoreLibraries($branch = null, $phpVersion = null) // name : 2pisoftware/cmfive-core // descrip. : // keywords : - // versions : * master + // versions : * main // type : library // source : [git] https://github.com/2pisoftware/cmfive-core develop // dist : [] @@ -321,7 +321,7 @@ function sketchComposerForCore($reference, $phpVersion) // name : 2pisoftware/cmfive-core // descrip. : // keywords : - // versions : * master + // versions : * main // type : library // source : [git] https://github.com/2pisoftware/cmfive-core develop // dist : [] @@ -337,7 +337,7 @@ function sketchComposerForCore($reference, $phpVersion) $phpVersion = "7.4"; } if (is_null($reference) || is_null($phpVersion)) { - $reference = is_null($reference) ? "master" : $reference; + $reference = is_null($reference) ? "main" : $reference; $phpVersion = is_null($phpVersion) ? (PHP_MAJOR_VERSION .".". PHP_MINOR_VERSION) : $phpVersion; } } diff --git a/test/Setup.txt b/test/Setup.txt index 36430f8..d24dad9 100644 --- a/test/Setup.txt +++ b/test/Setup.txt @@ -1,7 +1,7 @@ 1) Clone/pull/download: https://github.com/2pisoftware/cmfive-boilerplate - Position it nicely for WebServer to find - - Match it to a CORE install (cmfive.php step[1] will clone MASTER from scratch) + - Match it to a CORE install (cmfive.php step[1] will clone main from scratch) - Make symlinks etc as required - Apply any other usual cmfive setup steps! - Enable TestRunner in cmfive-boilerplate\config.php: diff --git a/test/playwright/cmfive.utils.ts b/test/playwright/cmfive.utils.ts index 42ae59d..1895ffa 100644 --- a/test/playwright/cmfive.utils.ts +++ b/test/playwright/cmfive.utils.ts @@ -69,4 +69,33 @@ export class CmfiveHelper { await page.locator('.ui-menu-item :text("' + value + '")').click(); } + // Finds substring in string with given position + static findString(target: string, searchText: string, searchPosition?: 'start' | 'end'): boolean { + if (searchPosition === 'start') { + return target.startsWith(searchText); + } else if (searchPosition === 'end') { + return target.endsWith(searchText); + } else { + return target.includes(searchText); + } + } + + // Finds a cell in a table by an item in its row and the column header + static async getColumnByText(page: Page, rowText: string, columnText: string, searchPosition?: 'start' | 'end'){ + const headers = page.locator('table thead tr th'); + let columnIndex: number | undefined; + + // iterate through the columns until a header contains, begins or starts with columnText + for (let i = 0; i < (await headers.count()); i++) { + const headerText = await headers.nth(i).textContent(); + if (CmfiveHelper.findString(headerText?.trim(),columnText, searchPosition)) { + columnIndex = i; // index for nth-child selector + break; + } + } + const row = CmfiveHelper.getRowByText(page, rowText); + return row.getByRole("cell").nth(columnIndex); + } + + }