From 818e68c9906d0537e0d9c790c6f2836a172aa19b Mon Sep 17 00:00:00 2001 From: Erez Voitiz Date: Tue, 6 Sep 2022 17:10:30 +0300 Subject: [PATCH 01/14] chore(gha): set tokens --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e696b6a..ba68f41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - name: Sprkl Setup uses: sprkl-dev/sprkl-action/setup@master with: - npm_token: ${{ secrets.USE_SPRKL_CI_TOKEN }} + npm: ${{ secrets.USE_SPRKL_CI_TOKEN }} setenv: false - run: yarn install From 95c22985a2e36d9f437d7c118171ec5af93cb3bf Mon Sep 17 00:00:00 2001 From: Erez Voitiz Date: Tue, 6 Sep 2022 17:11:25 +0300 Subject: [PATCH 02/14] chore(gha): execute ci on PRs --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba68f41..c54af3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ on: push: branches: - '**' + pull_request: + branches: + - '**' jobs: install-sprkl-test: runs-on: ubuntu-latest @@ -13,7 +16,7 @@ jobs: - name: Sprkl Setup uses: sprkl-dev/sprkl-action/setup@master with: - npm: ${{ secrets.USE_SPRKL_CI_TOKEN }} + token: ${{ secrets.USE_SPRKL_CI_TOKEN }} setenv: false - run: yarn install From 2a40cb413167352805e519f2185cfc678918bca0 Mon Sep 17 00:00:00 2001 From: Erez Voitiz Date: Wed, 7 Sep 2022 10:26:42 +0300 Subject: [PATCH 03/14] chore(gha): instrument code changes only --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c54af3c..596209e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,4 @@ jobs: - run: yarn install - run: yarn test:e2e:sprkl - env: - SPRKL_RECIPE: all From 861ce64a5ef674f68333fbc9b2a51c9d4291caca Mon Sep 17 00:00:00 2001 From: Erez Voitiz Date: Wed, 7 Sep 2022 11:25:03 +0300 Subject: [PATCH 04/14] feat(metrics): added metrics --- metrics/metrics.js | 15 +++++++++++++++ orders/index.js | 1 + 2 files changed, 16 insertions(+) diff --git a/metrics/metrics.js b/metrics/metrics.js index 03ead12..c614a41 100644 --- a/metrics/metrics.js +++ b/metrics/metrics.js @@ -17,6 +17,21 @@ mongoose.connect(`mongodb://${process.env.MONGO_HOST}/mern`, { useCreateIndex: true, }); +app.put('/updateMetrics', async (req, res) => { + try { + const metrics = await utils.retrieveMetrics(); + if (new Date().getDay() == 7) { + metrics.saturdaysCounter++; + } else { + metrics.totalCounter++; + } + await utils.updateMetrics(metrics); + res.sendStatus(200); + } catch(ex) { + res.status(401).send({ message: 'Failed updating metrics' + ex}); + } +}); + app.get('/metrics', async (req, res) => { const metrics = await utils.getMetrics(); res.send({ diff --git a/orders/index.js b/orders/index.js index c7a09f4..65f1f69 100644 --- a/orders/index.js +++ b/orders/index.js @@ -52,6 +52,7 @@ fastify.post('/orders', async function (request, reply) { order.state = 'landed' ordersCollection.insertOne(order); reply.send(order.state).code(200); + await axios.put('http://metrics:3000/updateMetrics') }) fastify.get('/orders', async function (request, reply) { From cf470911ef03ba82862451f7758d618fcfdda17a Mon Sep 17 00:00:00 2001 From: Erez Voitiz Date: Thu, 8 Sep 2022 09:42:26 +0300 Subject: [PATCH 05/14] fix(gha): fetch depth --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 596209e..5e1748d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Sprkl Setup uses: sprkl-dev/sprkl-action/setup@master From b5a1a5600769b93613255d6f2c2b4a825ef6e9cb Mon Sep 17 00:00:00 2001 From: Erez Voitiz Date: Thu, 15 Sep 2022 16:21:37 +0300 Subject: [PATCH 06/14] feat(devcontainer): added devcontainer configuration --- .devcontainer/Dockerfile | 9 +++++++++ .devcontainer/devcontainer.json | 15 +++++++++++++++ docker-compose.yml | 2 -- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..97aa3cc --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,9 @@ +FROM sprkldev/sprkl-node:0.0.43 + +RUN apk add git curl docker + +RUN mkdir -p /root/.docker/cli-plugins && \ + curl -SL https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-linux-x86_64 -o /root/.docker/cli-plugins/docker-compose && \ + chmod +x /root/.docker/cli-plugins/docker-compose + +ENV DOCKER_HOST=unix:///var/run/docker-host.sock \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..5340c11 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,15 @@ +{ + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04 + // Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon. + "args": { "VARIANT": "ubuntu-22.04" } + }, + "customizations": { + "vscode": { + "extensions": ["sprkldev.sprkl-vscode"] + } + }, + "mounts": ["source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"], + "runArgs": ["--network=host"] +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 26fd19b..8e67035 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,8 +50,6 @@ services: VITE_CATALOG_URL: http://catalog:3000 VITE_ORDERS_URL: http://orders:3000 VITE_PAYMENTS_URL: http://payments:3000 - volumes: - - "./shop/src:/code/src" ports: - "80:5000" From 79e24df27394fd0a96dab25dc92adf420c739962 Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Mon, 19 Sep 2022 13:27:33 +0300 Subject: [PATCH 07/14] testing sprkl application --- testfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile diff --git a/testfile b/testfile new file mode 100644 index 0000000..e69de29 From aebc731ffdac01e1c47f8e3b585b0d08272f9cef Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Mon, 19 Sep 2022 14:03:55 +0300 Subject: [PATCH 08/14] testfile2 --- testfile2 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile2 diff --git a/testfile2 b/testfile2 new file mode 100644 index 0000000..e69de29 From b0e2f6a94a324a6c9fc4b0a8d6d68e1c7a1d4daf Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Mon, 19 Sep 2022 16:28:57 +0300 Subject: [PATCH 09/14] testfile3 --- testfile3 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile3 diff --git a/testfile3 b/testfile3 new file mode 100644 index 0000000..e69de29 From c911f2d6e08cfc2002e723cbc684417b027b55be Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Mon, 19 Sep 2022 16:53:43 +0300 Subject: [PATCH 10/14] testfile4 --- testfile4 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile4 diff --git a/testfile4 b/testfile4 new file mode 100644 index 0000000..e69de29 From fdc4eaee04a138647b85204b42a7edad85d4f351 Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Mon, 19 Sep 2022 19:19:58 +0300 Subject: [PATCH 11/14] testfile5 --- testfile5 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile5 diff --git a/testfile5 b/testfile5 new file mode 100644 index 0000000..e69de29 From 18d36aa253a99bb026669130f60fa8b6d49dc1be Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Tue, 20 Sep 2022 14:43:23 +0300 Subject: [PATCH 12/14] testfile6 --- testfile6 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile6 diff --git a/testfile6 b/testfile6 new file mode 100644 index 0000000..e69de29 From 99fad03f5bd446deb878611d5415fa304d9d7c54 Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Tue, 20 Sep 2022 15:00:05 +0300 Subject: [PATCH 13/14] testfile7 --- testfile7 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile7 diff --git a/testfile7 b/testfile7 new file mode 100644 index 0000000..e69de29 From 18eb9d405dccf80050a66ff287cf0eb8c756e907 Mon Sep 17 00:00:00 2001 From: Raz Cohen Date: Tue, 20 Sep 2022 15:09:13 +0300 Subject: [PATCH 14/14] testfile8 --- testfile8 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 testfile8 diff --git a/testfile8 b/testfile8 new file mode 100644 index 0000000..e69de29