Skip to content

Commit 14ec022

Browse files
committed
Merging PlanetScale examples into repository
1 parent a210fce commit 14ec022

31 files changed

+7764
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Matrix Build Custom Runner
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image_url:
7+
description: Image URL
8+
required: true
9+
default: "images/matrix-finished.png"
10+
duration:
11+
description: 'Number of job duration in ms'
12+
required: true
13+
default: '500'
14+
x:
15+
description: 'Number of cells on x-Axis'
16+
required: true
17+
default: '16'
18+
y:
19+
description: 'Number of cells on y-Axis'
20+
required: true
21+
default: '12'
22+
pixel-x:
23+
description: 'Number of pixels on x-Axis'
24+
required: true
25+
default: '800'
26+
pixel-y:
27+
description: 'Number of pixels on y-Axis'
28+
required: true
29+
default: '600'
30+
repetitions:
31+
description: 'Number of matrix cell render cycles'
32+
required: true
33+
default: '1'
34+
repetition-delay:
35+
description: 'Wait time in ms between render cycles'
36+
required: true
37+
default: '5000'
38+
connections-per-cell:
39+
description: 'DB connections per matrix cell'
40+
required: true
41+
default: '1'
42+
43+
44+
jobs:
45+
46+
enter-matrix:
47+
name: "Render Matrix Cell"
48+
runs-on: custom-runner
49+
50+
strategy:
51+
fail-fast: false
52+
#max-parallel: 16
53+
matrix:
54+
x: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
55+
y: [1,2,3,4,5,6,7,8,9,10,11,12]
56+
57+
steps:
58+
- name: checkout
59+
uses: actions/checkout@v2
60+
61+
- name: Stream pixels into DB
62+
env:
63+
DATABASE_URL: ${{secrets.DATABASE_URL}}
64+
run: python3 render-matrix-cell.py --max-x='${{github.event.inputs.pixel-x}}' --max-y='${{github.event.inputs.pixel-y}}' --job-x='${{matrix.x}}' --job-y='${{matrix.y}}' --max-job-x='${{github.event.inputs.x}}' --max-job-y='${{github.event.inputs.y}}' --duration='${{github.event.inputs.duration}}' --environment=--environment='${{github.actor}}' --image-file='${{ github.event.inputs.image_url }}' --repetitions '${{github.event.inputs.repetitions}}' --connections '${{github.event.inputs.connections-per-cell}}' --repetition-delay '${{github.event.inputs.repetition-delay}}'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Matrix Build Hosted Runner
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image_url:
7+
description: Image URL
8+
required: true
9+
default: "images/matrix-finished.png"
10+
duration:
11+
description: 'Number of job duration in ms'
12+
required: true
13+
default: '500'
14+
x:
15+
description: 'Number of cells on x-Axis'
16+
required: true
17+
default: '16'
18+
y:
19+
description: 'Number of cells on y-Axis'
20+
required: true
21+
default: '12'
22+
pixel-x:
23+
description: 'Number of pixels on x-Axis'
24+
required: true
25+
default: '800'
26+
pixel-y:
27+
description: 'Number of pixels on y-Axis'
28+
required: true
29+
default: '600'
30+
repetitions:
31+
description: 'Number of matrix cell render cycles'
32+
required: true
33+
default: '1'
34+
repetition-delay:
35+
description: 'Wait time in ms between render cycles'
36+
required: true
37+
default: '30000'
38+
connections-per-cell:
39+
description: 'DB connections per matrix cell'
40+
required: true
41+
default: '1'
42+
43+
jobs:
44+
45+
enter-matrix:
46+
name: "Render Matrix Cell"
47+
runs-on: ubuntu-latest
48+
container:
49+
image: ghcr.io/jonico/actions-runner:ps
50+
options: --user root
51+
52+
strategy:
53+
fail-fast: false
54+
#max-parallel: 16
55+
matrix:
56+
x: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
57+
y: [1,2,3,4,5,6,7,8,9,10,11,12]
58+
59+
steps:
60+
- name: checkout
61+
uses: actions/checkout@v2
62+
63+
- name: Stream pixels into PlanetScale DB
64+
env:
65+
DATABASE_URL: ${{secrets.DATABASE_URL}}
66+
run: python3 render-matrix-cell.py --max-x='${{github.event.inputs.pixel-x}}' --max-y='${{github.event.inputs.pixel-y}}' --job-x='${{matrix.x}}' --job-y='${{matrix.y}}' --max-job-x='${{github.event.inputs.x}}' --max-job-y='${{github.event.inputs.y}}' --duration='${{github.event.inputs.duration}}' --environment='${{github.actor}}' --image-file='${{ github.event.inputs.image_url }}' --repetitions '${{github.event.inputs.repetitions}}' --connections '${{github.event.inputs.connections-per-cell}}' --repetition-delay '${{github.event.inputs.repetition-delay}}'

Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM ghcr.io/jonico/codespace-with-vnc-chrome-and-ps:latest
2+
3+
COPY fluxbox/menu /home/vscode/.fluxbox/
4+
5+
VOLUME [ "/var/lib/docker" ]
6+
7+
8+
ENV DBUS_SESSION_BUS_ADDRESS="autolaunch:" \
9+
VNC_RESOLUTION="1440x768x16" \
10+
VNC_DPI="96" \
11+
VNC_PORT="5901" \
12+
NOVNC_PORT="6080" \
13+
DISPLAY=":1" \
14+
LANG="en_US.UTF-8" \
15+
LANGUAGE="en_US.UTF-8"
16+
ENTRYPOINT ["/usr/local/share/desktop-init.sh", "/usr/local/share/docker-init.sh" ]
17+
CMD ["sleep", "infinity"]

Dockerfile.base

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
4+
ARG VARIANT="3.9"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6+
7+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
# [Option] Install zsh
12+
ARG INSTALL_ZSH="true"
13+
# [Option] Upgrade OS packages to their latest versions
14+
ARG UPGRADE_PACKAGES="false"
15+
# [Option] Enable non-root Docker access in container
16+
ARG ENABLE_NONROOT_DOCKER="true"
17+
# [Option] Use the OSS Moby Engine instead of the licensed Docker Engine
18+
ARG USE_MOBY="true"
19+
20+
# Install needed packages and setup non-root user. Use a separate RUN statement to add your
21+
# own dependencies. A user of "automatic" attempts to reuse an user ID if one already exists.
22+
ARG USERNAME=automatic
23+
ARG USER_UID=1000
24+
ARG USER_GID=$USER_UID
25+
26+
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
27+
COPY requirements.txt /tmp/pip-tmp/
28+
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
29+
&& rm -rf /tmp/pip-tmp
30+
31+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
32+
# && apt-get -y install --no-install-recommends <your-package-list-here>
33+
34+
35+
# [Optional] Uncomment this line to install global node packages.
36+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
37+
38+
RUN curl https://raw.githubusercontent.com/nektos/act/master/install.sh > /tmp/install-act.sh \
39+
&& chmod a+x /tmp/install-act.sh \
40+
&& /tmp/install-act.sh v0.2.20
41+
42+
COPY library-scripts/*.sh /tmp/library-scripts/
43+
44+
45+
RUN apt-get update \
46+
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
47+
&& /bin/bash /tmp/library-scripts/desktop-lite-debian.sh \
48+
# Use Docker script from script library to set things up
49+
&& /bin/bash /tmp/library-scripts/docker-in-docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "${USERNAME}" "${USE_MOBY}" \
50+
&& apt-get -y install --no-install-recommends mariadb-client \
51+
&& wget https://github.com/planetscale/cli/releases/download/v0.77.0/pscale_0.77.0_linux_amd64.deb \
52+
&& dpkg -i pscale_0.77.0_linux_amd64.deb \
53+
&& apt-get update && export DEBIAN_FRONTEND=noninteractive \
54+
&& curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /tmp/chrome.deb \
55+
&& apt-get -y install /tmp/chrome.deb \
56+
&& ALIASES="alias google-chrome='google-chrome --disable-dev-shm-usage'\nalias google-chrome-stable='google-chrome-stable --disable-dev-shm-usage'\n\alias x-www-browser='x-www-browser --disable-dev-shm-usage'\nalias gnome-www-browser='gnome-www-browser --disable-dev-shm-usage'" \
57+
&& echo "${ALIASES}" >> tee -a /etc/bash.bashrc \
58+
&& if type zsh > /dev/null 2>&1; then echo "${ALIASES}" >> /etc/zsh/zshrc; fi \
59+
# Clean up
60+
&& rm pscale_0.77.0_linux_amd64.deb \
61+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"inputs": {
3+
"image_url": "images/non-blocking-schema-change-text.png",
4+
"reset_image_url" : "images/ps-start.png",
5+
"pixel-x": "800",
6+
"pixel-y": "600",
7+
"x": "16",
8+
"y": "12",
9+
"repetitions": "2",
10+
"repetition-delay": "60000",
11+
"duration": "1000",
12+
"connections-per-cell": "10"
13+
}
14+
}

0 commit comments

Comments
 (0)