Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit 539d29f

Browse files
authored
Merge pull request #33 from HellPat/run-cypress-tests
runs cypress
2 parents 5ed8516 + 6e8ef26 commit 539d29f

11 files changed

Lines changed: 127 additions & 55 deletions

File tree

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ MESSENGER_TRANSPORT_DSN=redis://${REDIS_SOCKET}?stream=messages
4444

4545
STRIPE_PROJECT_NAME=subscribe
4646
STRIPE_DEVICE_NAME=developer-${DEVELOPER_NAME:-default}
47-
STRIPE_API_KEY=sk_test_51IHFU3H5sb6o9949VJorc2HKKiXJ8Q5gh4cSKrRrvHmu2FRVoIYoHxygkUEji2WgKFgVpmYxHnV7WDjRLm3sUyIx00HIEjLSeh

.github/workflows/main.yaml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
- vendor/bin/phpstan --error-format=github
2222
- vendor/bin/ecs
2323
- bin/console lint:twig templates --no-interaction --format=github
24-
- bin/console lint:yaml . *.yaml --parse-tags --no-interaction --format=github
2524
- bin/console lint:container --no-interaction
2625
- bin/console lint:xliff translations --no-interaction --format=github
2726
- composer validate composer.json --no-check-publish
2827
- symfony security:check
2928
# TODO: add more ci-checks
29+
# bin/console lint:yaml *.yaml --parse-tags --no-interaction --format=github
3030
# vendor/bin/parallel-lint src public migrations config
3131
# XDEBUG_MODE=off bin/composer-require-checker --no-interaction --config-file=$PWD/composer-require-checker.json
3232
# vendor/bin/config-transformer --dry-run
@@ -37,21 +37,57 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v4
3939
- uses: cachix/install-nix-action@v25
40+
with:
41+
nix_path: nixpkgs=channel:nixos-unstable
4042
# TODO: cache composer dependencies
4143
# TODO: check why --ignore-platform-req=ext-redis is needed
42-
- run: composer install --ignore-platform-req=ext-redis
43-
- run: bin/console cache:warmup
44+
- run: just setup-backend
4445
- run: ${{ matrix.check }}
4546

4647
phpunit:
4748
runs-on: ubuntu-latest
49+
defaults:
50+
run:
51+
shell: nix-shell --pure --run "bash -euxo pipefail {0}"
4852
steps:
4953
- uses: actions/checkout@v4
5054
- uses: cachix/install-nix-action@v25
55+
with:
56+
nix_path: nixpkgs=channel:nixos-unstable
5157
# TODO: cache the build
52-
- shell: nix-shell --pure --run "bash -euxo pipefail {0}"
58+
- run: just setup-backend
59+
- run: XDEBUG_MODE=coverage vendor/bin/phpunit --order-by=random --stop-on-error --stop-on-failure
60+
61+
functional-tests:
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v4
65+
- uses: cachix/install-nix-action@v25
66+
with:
67+
nix_path: nixpkgs=channel:nixos-unstable
68+
- uses: pnpm/action-setup@v2
69+
with:
70+
run_install: false
71+
- name: Get pnpm store directory
72+
shell: bash
5373
run: |
54-
# TODO: cache composer dependencies
55-
# TODO: check why --ignore-platform-req=ext-redis is needed
56-
composer install --ignore-platform-req=ext-redis
57-
XDEBUG_MODE=coverage vendor/bin/phpunit --order-by=random --stop-on-error --stop-on-failure
74+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
75+
- uses: actions/cache@v3
76+
name: Setup pnpm cache
77+
with:
78+
path: ${{ env.STORE_PATH }}
79+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
80+
restore-keys: |
81+
${{ runner.os }}-pnpm-store-
82+
- name: Install dependencies
83+
run: pnpm install --frozen-lockfile --strict-peer-dependencies
84+
- shell: nix-shell --pure --run "bash -euxo pipefail {0}"
85+
run: just setup
86+
- shell: nix-shell --pure --run "bash -euxo pipefail {0}"
87+
run: just start-background
88+
- shell: nix-shell --pure --run "bash -euxo pipefail {0}"
89+
run: bin/console doctrine:migrations:migrate --allow-no-migration --no-interaction
90+
- uses: cypress-io/github-action@v6
91+
92+
93+

Justfile

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1+
start-background:
2+
overmind start -D
3+
14
develop:
25
overmind start
36

4-
build:
7+
setup:
8+
just setup-backend
9+
just setup-database
10+
just setup-frontend
11+
just setup-stripe
12+
13+
setup-database:
514
#!/usr/bin/env bash
615
set -euxo pipefail
7-
# initialize mysql when the directory does not exist
8-
if [ ! -d $MYSQL_DATADIR ]; then
9-
mkdir -p ${MYSQL_DATADIR}
10-
mysqld --datadir=${MYSQL_DATADIR} --initialize
11-
fi
12-
echo "STRIPE_SIGNING_SECRET=$(stripe listen --print-secret)" > .env.local
13-
tailwindcss -i assets/styles/app.css -o assets/styles/app.tailwind.css
16+
${MYSQL_HOME}/init.sh
17+
18+
setup-backend:
19+
#!/usr/bin/env bash
20+
set -euxo pipefail
21+
composer install --ignore-platform-req=ext-redis
22+
bin/console cache:warmup
1423

15-
rebuild:
16-
bin/console d:d:d --force
17-
bin/console d:d:c --no-interaction
18-
bin/console d:m:m --no-interaction
19-
bin/console d:s:u --complete --dump-sql
20-
just build
24+
setup-frontend:
25+
#!/usr/bin/env bash
26+
set -euxo pipefail
27+
tailwindcss -i assets/styles/app.css -o assets/styles/app.tailwind.css
2128

22-
stripe-listen:
23-
# Write the Stripe signing secret to .env.local, to be used by the webhook handler.
24-
# TODO: this works but it's not ideal.
25-
# The file is overwritten every time the command is run,
26-
# we should instead add or replace only the STRIPE_SIGNING_SECRET line.
27-
#
28-
# An other solution could be, to use an API-Token instead.
29+
setup-stripe:
30+
#!/usr/bin/env bash
31+
set -euxo pipefail
32+
# TODO: secret should not rely on a file
2933
echo "STRIPE_SIGNING_SECRET=$(stripe listen --print-secret)" > .env.local
30-
stripe listen --skip-verify --forward-to localhost:8000/webhook/stripe
3134

3235
lint:
3336
vendor/bin/psalm

Procfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TODO: handle dependencies between services by using a wait-for.sh script.
22

3-
mysql: mysqld --datadir=${MYSQL_DATADIR} --init-file=${MYSQL_HOME}/init.sql --skip-networking
4-
redis: redis-server storage/redis/redis.conf
3+
mysql: mysqld --basedir=${MYSQL_HOME}/ --datadir=${MYSQL_DATADIR}/ --init-file=${MYSQL_HOME}/init.sql --skip-networking --default-time-zone=SYSTEM --log-error=${TMPDIR}/error.log --lc_messages_dir=${TMPDIR}/ --lc_messages=en_US --console
4+
redis: envsubst < storage/redis/redis.conf | redis-server -
55
symfony: rr serve -p -c .rr.dev.yaml --debug
66

77
# TODO: rethink limits and restarts.

assets/styles/app.tailwind.css

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
! tailwindcss v3.3.5 | MIT License | https://tailwindcss.com
2+
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
33
*/
44

55
/*
@@ -32,9 +32,11 @@
3232
4. Use the user's configured `sans` font-family by default.
3333
5. Use the user's configured `sans` font-feature-settings by default.
3434
6. Use the user's configured `sans` font-variation-settings by default.
35+
7. Disable tap highlights on iOS
3536
*/
3637

37-
html {
38+
html,
39+
:host {
3840
line-height: 1.5;
3941
/* 1 */
4042
-webkit-text-size-adjust: 100%;
@@ -44,12 +46,14 @@ html {
4446
-o-tab-size: 4;
4547
tab-size: 4;
4648
/* 3 */
47-
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
49+
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
4850
/* 4 */
4951
font-feature-settings: normal;
5052
/* 5 */
5153
font-variation-settings: normal;
5254
/* 6 */
55+
-webkit-tap-highlight-color: transparent;
56+
/* 7 */
5357
}
5458

5559
/*
@@ -121,8 +125,10 @@ strong {
121125
}
122126

123127
/*
124-
1. Use the user's configured `mono` font family by default.
125-
2. Correct the odd `em` font sizing in all browsers.
128+
1. Use the user's configured `mono` font-family by default.
129+
2. Use the user's configured `mono` font-feature-settings by default.
130+
3. Use the user's configured `mono` font-variation-settings by default.
131+
4. Correct the odd `em` font sizing in all browsers.
126132
*/
127133

128134
code,
@@ -131,8 +137,12 @@ samp,
131137
pre {
132138
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
133139
/* 1 */
134-
font-size: 1em;
140+
font-feature-settings: normal;
135141
/* 2 */
142+
font-variation-settings: normal;
143+
/* 3 */
144+
font-size: 1em;
145+
/* 4 */
136146
}
137147

138148
/*

cypress.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { defineConfig } = require("cypress");
22

33
module.exports = defineConfig({
44
e2e: {
5+
supportFile: false,
56
setupNodeEvents(on, config) {
67
// implement node event listeners here
78
},

cypress/e2e/todo.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ describe('customers', () => {
2929

3030
// TODO: retry the reload until it's there
3131
// waiting is bad, as it slows down the tests
32-
cy.wait(500)
32+
cy.wait(5000)
3333
cy.reload()
3434

3535
// check if the email address is visible in the list of customers
36-
cy.get('[data-test="customer.list"] tbody > tr', { timeout: 10000 }).contains(email)
36+
cy.get('[data-test="customer.list"] tbody > tr').contains(email)
3737
})
3838
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"packageManager": "pnpm@8.14.0",
23
"devDependencies": {
34
"cypress": "^13.6.3",
45
"stripe": "^14.13.0",

shell.nix

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# https://nix.dev/tutorials/first-steps/towards-reproducibility-pinning-nixpkgs#pinning-packages-with-urls-inside-a-nix-expression
44
# Picking the commit can be done via https://status.nixos.org,
55
# which lists all the releases and the latest commit that has passed all tests.
6-
pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d7f206b723e42edb09d9d753020a84b3061a79d8.tar.gz") {},
6+
pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/854f4671883250e456dc1553c783ac9741a0e9a4.tar.gz") {},
77
php ? pkgs.php83.buildEnv {
88
extensions = ({ enabled, all }: enabled ++ (with all; [
99
redis
@@ -48,19 +48,22 @@ pkgs.mkShell {
4848
pkgs.mysql80
4949
pkgs.hostname
5050
pkgs.redis
51+
pkgs.envsubst
5152
];
5253

53-
# TODO: configure dynamically to use the current directory
54-
MYSQL_HOME= "/home/pheller/Code/groupware/storage/mysql";
55-
MYSQL_DATADIR = "/home/pheller/Code/groupware/storage/mysql/data";
56-
MYSQL_UNIX_PORT = "/home/pheller/Code/groupware/.mysql.sock";
57-
MYSQLX_UNIX_PORT = "/home/pheller/Code/groupware/.mysqlx.sock";
58-
59-
REDIS_DATADIR = "/home/pheller/Code/groupware/storage/redis/data";
60-
REDIS_PID = "/home/pheller/Code/groupware/.redis.pid";
61-
REDIS_SOCKET = "/home/pheller/Code/groupware/.redis.sock";
62-
6354
shellHook = ''
55+
export MYSQL_HOME=''${PWD}/storage/mysql
56+
export MYSQL_DATADIR=''${PWD}/storage/mysql/data
57+
export MYSQL_UNIX_PORT=''${PWD}/.mysql.sock
58+
export MYSQLX_UNIX_PORT=''${PWD}/.mysqlx.sock
59+
export REDIS_DATADIR=''${PWD}/storage/redis/data
60+
export REDIS_PID=''${PWD}/.redis.pid
61+
export REDIS_SOCKET=''${PWD}/.redis.sock
62+
export STRIPE_PROJECT_NAME=subscribe
63+
export STRIPE_DEVICE_NAME=developer-''${DEVELOPER_NAME:-default}
64+
# TODO: move secret to a vault
65+
export STRIPE_API_KEY=sk_test_51IHFU3H5sb6o9949VJorc2HKKiXJ8Q5gh4cSKrRrvHmu2FRVoIYoHxygkUEji2WgKFgVpmYxHnV7WDjRLm3sUyIx00HIEjLSeh
66+
source .env
6467
redis-server -v
6568
mysql --version
6669
git --version

storage/mysql/init.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
touch ${TMPDIR}/errmsg.sys
5+
touch ${TMPDIR}/error.log
6+
7+
# initialize mysql when the directory does not exist
8+
if [ ! -d ${MYSQL_DATADIR} ]; then
9+
mkdir -p ${MYSQL_DATADIR}
10+
mysqld \
11+
--basedir=${MYSQL_HOME}/ \
12+
--datadir=${MYSQL_DATADIR}/ \
13+
--initialize-insecure \
14+
--default-time-zone=SYSTEM \
15+
--log-error=${TMPDIR}/error.log \
16+
--lc_messages_dir=${TMPDIR} \
17+
--lc_messages=en_US \
18+
--console
19+
fi

0 commit comments

Comments
 (0)