Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:2pisoftware/cmfive-boilerplate i…
Browse files Browse the repository at this point in the history
…nto feat/AddXdebugSupport
  • Loading branch information
mattbell87 committed Aug 19, 2024
2 parents bd354df + 0230f94 commit 19fa20e
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .codepipeline/docker/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 [email protected] admin admin
php cmfive.php seed admin admin admin [email protected] admin admin
fi

#Let container know that everything is finished
Expand Down
33 changes: 30 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
pull_request:
branches:
- develop
- master
push:
tags:
- 'v*'
branches:
- develop
- master

jobs:
build-and-publish:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -51,20 +59,39 @@ 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
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
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 }}
Expand Down
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==
Expand Down Expand Up @@ -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/ && \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmfive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 : []
Expand Down Expand Up @@ -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 : []
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/Setup.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
29 changes: 29 additions & 0 deletions test/playwright/cmfive.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


}

0 comments on commit 19fa20e

Please sign in to comment.