Skip to content

Commit

Permalink
Merge pull request #3 from ba-st/project-loading
Browse files Browse the repository at this point in the history
Add scripting for loading rowan projects
  • Loading branch information
gcotelli authored Aug 2, 2023
2 parents 64e1682 + 5017fcb commit 5262d6a
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 31 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ jobs:
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

# GS64 base image
- name: Gather docker meta data for base image
# GS64 server image
- name: Gather docker meta data for server image
id: docker_meta_runtime
uses: crazy-max/ghaction-docker-meta@v4
with:
images: ghcr.io/${{ github.repository_owner }}/gs64

- name: Docker build and push base image
- name: Docker build and push server image
uses: docker/build-push-action@v4
with:
context: ./source
file: ./source/Dockerfile
build-args: GS_VERSION=${{ matrix.version }}
target: docker-gs64-base
target: docker-gs64-server
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta_runtime.outputs.tags }}
labels: ${{ steps.docker_meta_runtime.outputs.labels }}
secrets: GIT_AUTH_TOKEN=${{ secrets.DOCKER_REGISTRY_TOKEN }}

# GS64 base image + rowan extent
# GS64 server image + rowan extent
- name: Gather docker meta data for rowan image
id: docker_meta_runtime_rowan
uses: crazy-max/ghaction-docker-meta@v4
Expand All @@ -71,21 +71,21 @@ jobs:
labels: ${{ steps.docker_meta_runtime_rowan.outputs.labels }}
secrets: GIT_AUTH_TOKEN=${{ secrets.DOCKER_REGISTRY_TOKEN }}

# GS64 base image + rowan extent + git
- name: Gather docker meta data for rowan-loader image
id: docker_meta_runtime_rowan_loader
# GS64 server image + base extent0.dbf
- name: Gather docker meta data for base image
id: docker_meta_runtime_base
uses: crazy-max/ghaction-docker-meta@v4
with:
images: ghcr.io/${{ github.repository_owner }}/gs64-rowan-loader
images: ghcr.io/${{ github.repository_owner }}/gs64-base

- name: Docker build and push rowan-loader image
- name: Docker build and push base image
uses: docker/build-push-action@v4
with:
context: ./source
file: ./source/Dockerfile
build-args: GS_VERSION=${{ matrix.version }}
target: docker-gs64-rowan-loader
target: docker-gs64-base
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta_runtime_rowan_loader.outputs.tags }}
labels: ${{ steps.docker_meta_runtime_rowan_loader.outputs.labels }}
tags: ${{ steps.docker_meta_runtime_base.outputs.tags }}
labels: ${{ steps.docker_meta_runtime_base.outputs.labels }}
secrets: GIT_AUTH_TOKEN=${{ secrets.DOCKER_REGISTRY_TOKEN }}
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ You can configure some things with environment variables:
- `/opt/gemstone/logs` Log files
- `/opt/gemstone/product/sys/gemstone.key` License key, by default `community.starter.key`
is used.

## Additional docs

- [How to load a Rowan project](how-to/how-to-load-rowan-project.md)
- [Docker images reference](reference/docker-images.md)
21 changes: 21 additions & 0 deletions docs/how-to/how-to-load-rowan-project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# How to load a Rowan project

`gs64-rowan` images contains some simple scripts to load a Rowan-aware project
from disk located in `ROWAN_PROJECTS_HOME`. Once you have started the image you
can do something like:

```bash
docker exec -it -e GS64_CI_PROJECT_NAME=Buoy examples-stone-1 ./load-rowan-project.sh
```

This will try to use `${ROWAN_PROJECTS_HOME}/Buoy/rowan/specs/Buoy-CI.ston` as the
loading specification.

The script supports the following configuration:

- `GS64_CI_PROJECT_NAME` is mandatory and will be used as the folder containing
the project to load
- `GS64_CI_SPEC` is optional. It's the name of the spec file to load.
Defaults to `${GS64_CI_PROJECT_NAME}-CI`
- `GS64_CI_SYSTEM_USER_PASSWORD` is optional. The password for the `SystemUser`
account in the mounted extent. Defaults to `swordfish`.
15 changes: 15 additions & 0 deletions docs/how-to/how-to-run-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# How to run tests for a Rowan project

`gs64-rowan` images contains some simple scripts to run the test of a loaded
Rowan-aware project. Once you have started the image you
can do something like:

```bash
docker exec -it examples-stone-1 ./run-tests.sh Buoy
```

The script supports the following configuration:

- The only accepted script argument is the rowan-aware project name
- `GS64_CI_SYSTEM_USER_PASSWORD` is optional. The password for the `SystemUser`
account in the mounted extent. Defaults to `swordfish`.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Docker images reference

## `gs64` base docker image
## `gs64` server docker image

This container image contains the GemStone/S 64 bits runtime support but doesn't
provide an `extent0.dbf`. Users will need to map a volume against `/opt/gemstone/data/`
containing the relevant data files (extents and transaction logs).

## `gs64-rowan` docker image

This container image builds on top of the base image providing the `extent0.rowan.dbf`.
It's a useful target for a CI system.

## `gs64-rowan-loader` docker image

This container image builds on top of the rowan image installing also git.
This container image builds on top of the server image providing the `extent0.rowan.dbf`
and a git installation. It's a useful target for a CI system.
In order to use Rowan for cloning and manipulating remote repositories, users
will need to map a volume against `/home/gemstone/.ssh/` containing the
relevant keys.

## `gs64-base` docker image

This container image builds on top of the server image providing the `extent0.dbf`
2 changes: 1 addition & 1 deletion examples/docker-compose.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
network_mode: host
build:
context: ../source
target: docker-gs64-rowan-loader
target: docker-gs64-rowan
args:
GS_VERSION: 3.6.6
environment:
Expand Down
2 changes: 1 addition & 1 deletion examples/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
stone:
init: true
network_mode: host
image: ghcr.io/ba-st/gs64-rowan-loader:v3.6.6
image: ghcr.io/ba-st/gs64-rowan:v3.6.6
environment:
TZ: America/Argentina/Buenos_Aires
volumes:
Expand Down
17 changes: 8 additions & 9 deletions source/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,19 @@ CMD ["./entrypoint.sh"]
## Prepare server rowan image
FROM docker-gs64-server as docker-gs64-rowan

ENV ROWAN_PROJECTS_HOME=${GEMSTONE_GLOBAL_DIR}/projects

RUN install -d --owner=${GS_USER} --group=users ${ROWAN_PROJECTS_HOME}
COPY --from=download --chown=${GS_USER}:users /tmp/extent0.rowan.dbf ${GEMSTONE_GLOBAL_DIR}/data/extent0.dbf
CMD ["./entrypoint.sh"]

## Prepare server rowan loader image
FROM docker-gs64-rowan as docker-gs64-rowan-loader

# Install git
RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends git \
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/* \
;

ENV ROWAN_PROJECTS_HOME=${GEMSTONE_GLOBAL_DIR}/projects

RUN install -d --owner=${GS_USER} --group=users ${ROWAN_PROJECTS_HOME}
COPY --chown=${GS_USER}:users load-rowan-project.sh ${GEMSTONE_GLOBAL_DIR}/load-rowan-project.sh
COPY --chown=${GS_USER}:users run-tests.sh ${GEMSTONE_GLOBAL_DIR}/run-tests.sh
COPY --chown=${GS_USER}:users StdOutPrinter.gs ${GEMSTONE_GLOBAL_DIR}/StdOutPrinter.gs

COPY --from=download --chown=${GS_USER}:users /tmp/extent0.rowan.dbf ${GEMSTONE_GLOBAL_DIR}/data/extent0.dbf
CMD ["./entrypoint.sh"]
73 changes: 73 additions & 0 deletions source/StdOutPrinter.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
set compile_env: 0
! ------------------- Class definition for StdOutPrinter
expectvalue /Class
doit
Object subclass: 'StdOutPrinter'
instVarNames: #()
classVars: #()
classInstVars: #()
poolDictionaries: #()
inDictionary: Globals
options: #()

%
! ------------------- Remove existing behavior from StdOutPrinter
expectvalue /Metaclass3
doit
StdOutPrinter removeAllMethods.
StdOutPrinter class removeAllMethods.
%
set compile_env: 0
! ------------------- Class methods for StdOutPrinter
category: 'printing'
classmethod: StdOutPrinter
printError: aBlock

self printLine: [:s |
s << Character esc << '[1m'.
s << Character esc << '[31m'.
aBlock value: s.
s << Character esc << '[0m'
].
%
category: 'printing'
classmethod: StdOutPrinter
printInfo: aBlock

self printLine: [:s |
s << Character esc << '[1m'.
s << Character esc << '[34m'.
aBlock value: s.
s << Character esc << '[0m'
].
%
category: 'printing'
classmethod: StdOutPrinter
printLine: aBlock

aBlock value: GsFile stdout.
GsFile stdout lf; flush
%
category: 'printing'
classmethod: StdOutPrinter
printSuccess: aBlock

self printLine: [:s |
s << Character esc << '[1m'.
s << Character esc << '[32m'.
aBlock value: s.
s << Character esc << '[0m'
].
%
category: 'printing'
classmethod: StdOutPrinter
printWarning: aBlock

self printLine: [:s |
s << Character esc << '[1m'.
s << Character esc << '[33m'.
aBlock value: s.
s << Character esc << '[0m'
].
%
! ------------------- Instance methods for StdOutPrinter
32 changes: 32 additions & 0 deletions source/load-rowan-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

if [ -z "${GS64_CI_PROJECT_NAME}" ]; then
echo "[ERROR] Missing GS64_CI_PROJECT_NAME variable"
exit 1
fi

readonly LOAD_SPEC="${GS64_CI_SPEC:-${GS64_CI_PROJECT_NAME}-CI}"
readonly SYSTEM_USER_PASSWORD="${GS64_CI_SYSTEM_USER_PASSWORD:-swordfish}"

echo "Loading code in GS..."
echo " Project Name: ${GS64_CI_PROJECT_NAME}"
echo " Load Spec: ${LOAD_SPEC}"

topaz -i -q <<EOF > "${GEMSTONE_LOG_DIR}/loading-rowan-projects.log"
set gemstone gs64stone user SystemUser pass ${SYSTEM_USER_PASSWORD}
iferror exit 1
login
doit
|spec url |
url := 'file://${ROWAN_PROJECTS_HOME}/${GS64_CI_PROJECT_NAME}/rowan/specs/${LOAD_SPEC}.ston'.
spec := RwSpecification fromUrl: url.
spec resolve load.
%
commit
logout
exit 0
EOF

echo "Loading code in GS... [OK]"
Loading

0 comments on commit 5262d6a

Please sign in to comment.