mirror of
https://github.com/opdavies/build-configs.git
synced 2025-03-13 05:26:56 +00:00
Add snapshot tests for Fractal
This commit is contained in:
parent
2186c29246
commit
31ef9b2968
|
@ -17,6 +17,7 @@ class SnapshotTest extends TestCase
|
|||
'drupal',
|
||||
'drupal-commerce-kickstart',
|
||||
'drupal-localgov',
|
||||
'fractal',
|
||||
];
|
||||
|
||||
public function testCompareFiles(): void
|
||||
|
@ -41,10 +42,12 @@ class SnapshotTest extends TestCase
|
|||
|
||||
private function runCliTool(string $config): void
|
||||
{
|
||||
$configFilePath = getcwd() . "/tests/snapshots/configs/{$config}.yaml";
|
||||
|
||||
$cliCommand = sprintf(
|
||||
"%s app:generate --config-file %s --output-dir %s",
|
||||
getcwd() . '/bin/build-configs',
|
||||
getcwd() . "/tests/snapshots/configs/{$config}.yaml",
|
||||
$configFilePath,
|
||||
getcwd() . "/.ignored/snapshots/output/{$config}",
|
||||
);
|
||||
|
||||
|
|
15
tests/snapshots/configs/fractal.yaml
Normal file
15
tests/snapshots/configs/fractal.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
name: docker-fractal
|
||||
language: javascript
|
||||
type: fractal
|
||||
|
||||
node:
|
||||
version: 20-bullseye-slim
|
||||
|
||||
dockerfile: []
|
||||
|
||||
docker-compose:
|
||||
services:
|
||||
- node
|
||||
|
||||
experimental:
|
||||
createGitHubActionsConfiguration: true
|
3
tests/snapshots/output/fractal/.dockerignore
Normal file
3
tests/snapshots/output/fractal/.dockerignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
README.md
|
8
tests/snapshots/output/fractal/.env.example
Normal file
8
tests/snapshots/output/fractal/.env.example
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
export DOCKER_UID=1000
|
||||
|
||||
export COMPOSE_PROJECT_NAME=docker-fractal
|
||||
export COMPOSE_PROFILES=node
|
||||
|
||||
export DOCKER_WEB_VOLUME=.:/app
|
27
tests/snapshots/output/fractal/.githooks/prepare-commit-msg
Executable file
27
tests/snapshots/output/fractal/.githooks/prepare-commit-msg
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
# Load the issue ID from an `.issue-id` file within the project and replace the
|
||||
# `ISSUE_ID` placeholder within a Git commit message.
|
||||
#
|
||||
# For example, running `echo "OD-123" > .issue-id` will add `Refs: OD-123` to
|
||||
# the commit message.
|
||||
#
|
||||
# This also works with multiple issue IDs in the same string, e.g.
|
||||
# "OD-123 OD-456", or IDs on multiple lines.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
PROJECT_DIR=$(git rev-parse --show-toplevel)
|
||||
ISSUE_FILE="$PROJECT_DIR/.issue-id"
|
||||
|
||||
if [ -f "${ISSUE_FILE}" ]; then
|
||||
ISSUE_IDS=$(cat "${ISSUE_FILE}" | tr '\n' ',' | tr ' ' ',' | sed 's/,$//' | sed 's/,/, /g')
|
||||
|
||||
if [ -n "${ISSUE_IDS}" ]; then
|
||||
sed -i.bak "s/# Refs:/Refs: $ISSUE_IDS/" "$1"
|
||||
fi
|
||||
fi
|
25
tests/snapshots/output/fractal/.github/workflows/ci.yml
vendored
Normal file
25
tests/snapshots/output/fractal/.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
COMPOSE_DOCKER_CLI_BUILD: 1
|
||||
DOCKER_BUILDKIT: 1
|
||||
DOCKER_UID: 1001
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
./run ci:build
|
9
tests/snapshots/output/fractal/.gitignore
vendored
Normal file
9
tests/snapshots/output/fractal/.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
node_modules
|
||||
|
||||
# Docker.
|
||||
.env
|
||||
docker-compose.override.yaml
|
||||
|
||||
|
2
tests/snapshots/output/fractal/.hadolint.yaml
Normal file
2
tests/snapshots/output/fractal/.hadolint.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
ignore:
|
||||
- DL3059
|
3
tests/snapshots/output/fractal/.yarnrc
Normal file
3
tests/snapshots/output/fractal/.yarnrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
--modules-folder /node_modules
|
20
tests/snapshots/output/fractal/Dockerfile
Normal file
20
tests/snapshots/output/fractal/Dockerfile
Normal file
|
@ -0,0 +1,20 @@
|
|||
FROM node:20-bullseye-slim AS base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir /node_modules \
|
||||
&& chown node:node -R /app /node_modules
|
||||
|
||||
COPY --chown=node:node package*.json *yarn* /app
|
||||
|
||||
USER node
|
||||
|
||||
################################################################################
|
||||
|
||||
FROM base AS build
|
||||
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
COPY --chown=node:node . .
|
||||
|
||||
CMD ["bash"]
|
44
tests/snapshots/output/fractal/docker-compose.yaml
Normal file
44
tests/snapshots/output/fractal/docker-compose.yaml
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
x-proxy: &default-proxy
|
||||
networks:
|
||||
- default
|
||||
- web
|
||||
labels:
|
||||
- "traefik.docker.network=traefik_proxy"
|
||||
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(
|
||||
`${COMPOSE_PROJECT_NAME}.localhost`,
|
||||
)"
|
||||
|
||||
x-app: &default-app
|
||||
volumes:
|
||||
- "${DOCKER_WEB_VOLUME:-./:/app}"
|
||||
env_file:
|
||||
- .env
|
||||
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
|
||||
networks:
|
||||
- default
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${DOCKER_MYSQL_CPUS:-0}"
|
||||
memory: "${DOCKER_MYSQL_MEMORY:-0}"
|
||||
labels:
|
||||
- "traefik.enabled=false"
|
||||
tty: true
|
||||
|
||||
services:
|
||||
|
||||
node:
|
||||
<<: [*default-proxy, *default-app]
|
||||
build:
|
||||
context: .
|
||||
target: build
|
||||
volumes:
|
||||
- .:/app
|
||||
profiles: [node]
|
||||
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
name: traefik_proxy
|
113
tests/snapshots/output/fractal/run
Executable file
113
tests/snapshots/output/fractal/run
Executable file
|
@ -0,0 +1,113 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
PATH="$PATH:./node_modules/.bin"
|
||||
|
||||
# If we're running in CI we need to disable TTY allocation for docker compose
|
||||
# commands that enable it by default, such as exec and run.
|
||||
TTY="${TTY:-}"
|
||||
if [[ ! -t 1 ]]; then
|
||||
TTY="-T"
|
||||
fi
|
||||
|
||||
# Remove and generated or temporary files.
|
||||
function build {
|
||||
cmd fractal build "${@}"
|
||||
}
|
||||
|
||||
function ci:build {
|
||||
cp -v --no-clobber .env.example .env
|
||||
|
||||
docker network create traefik_proxy || true
|
||||
|
||||
docker compose up -d
|
||||
|
||||
build
|
||||
}
|
||||
|
||||
# Remove and generated or temporary files.
|
||||
function clean {
|
||||
rm -fr build node_modules
|
||||
touch build/.keep
|
||||
}
|
||||
|
||||
# Disable Git hooks.
|
||||
function git-hooks:off {
|
||||
git config --unset core.hooksPath
|
||||
}
|
||||
|
||||
# Enable Git hooks.
|
||||
function git-hooks:on {
|
||||
git config core.hooksPath .githooks
|
||||
}
|
||||
|
||||
# Create a new Fractal component.
|
||||
function fractal:new {
|
||||
mkdir -p "components/${1}"
|
||||
|
||||
echo "name: ${1}" > "components/${1}/${1}.config.yml"
|
||||
echo "${1}" > "components/${1}/${1}.twig"
|
||||
}
|
||||
|
||||
# Display a list of all available commands.
|
||||
function help {
|
||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||
|
||||
compgen -A function | grep -v "^_" | cat -n
|
||||
|
||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||
}
|
||||
|
||||
# Start the project.
|
||||
function start {
|
||||
cp -v --no-clobber .env.example .env
|
||||
docker compose up -d
|
||||
}
|
||||
|
||||
function sync {
|
||||
clean
|
||||
fractal build
|
||||
|
||||
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
||||
--acl "public-read" \
|
||||
--cache-control max-age=3600
|
||||
}
|
||||
|
||||
# Run a command within the node container.
|
||||
function cmd {
|
||||
docker compose exec node yarn "${@}"
|
||||
}
|
||||
|
||||
# Stop the project
|
||||
function stop {
|
||||
docker compose down
|
||||
}
|
||||
|
||||
# Execute yarn commands.
|
||||
function yarn {
|
||||
cmd node yarn "${@}"
|
||||
}
|
||||
|
||||
function _run {
|
||||
local service="${1}"
|
||||
local command="${2}"
|
||||
|
||||
docker compose run \
|
||||
--entrypoint "${command}" \
|
||||
--no-deps \
|
||||
--rm \
|
||||
-T \
|
||||
"${service}" "${@}"
|
||||
}
|
||||
|
||||
# Include any local tasks.
|
||||
[[ -e run.local ]] && source run.local
|
||||
|
||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||
time "${@:-help}"
|
||||
|
||||
# vim: ft=bash
|
Loading…
Reference in a new issue