diff --git a/.devcontainer/gherkin-test/devcontainer.json b/.devcontainer/gherkin-test/devcontainer.json new file mode 100644 index 00000000..84c40f9e --- /dev/null +++ b/.devcontainer/gherkin-test/devcontainer.json @@ -0,0 +1,4 @@ +{ + "image": "ghcr.io/philips-software/amp-devcontainer-gherkin:${localEnv:IMAGE_VERSION}", + "workspaceFolder": "/workspaces/amp-devcontainer/test/gherkin/workspace" +} diff --git a/.devcontainer/gherkin/Dockerfile b/.devcontainer/gherkin/Dockerfile new file mode 100644 index 00000000..a4acc67a --- /dev/null +++ b/.devcontainer/gherkin/Dockerfile @@ -0,0 +1,36 @@ +FROM ubuntu:24.04@sha256:b59d21599a2b151e23eea5f6602f4af4d7d31c4e236d22bf0b62b86d2e386b8f + +ARG BATS_VERSION=1.11.0 +ARG NODE_MAJOR=20 + +ARG DEBIAN_FRONTEND=noninteractive + +HEALTHCHECK NONE + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Install the base system with all tool dependencies +# hadolint ignore=DL3008 +RUN --mount=type=bind,source=.devcontainer/gherkin/apt-requirements-base.json,target=/tmp/apt-requirements-base.json \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=cache,target=/var/log,sharing=locked \ + apt-get update && apt-get install -y --no-install-recommends jq \ + && jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-base.json | \ + xargs apt-get install -y --no-install-recommends \ + # Include the Cisco Umbrella PKI Root + && wget -qO /usr/local/share/ca-certificates/Cisco_Umbrella_Root_CA.crt https://www.cisco.com/security/pki/certs/ciscoumbrellaroot.pem \ + && update-ca-certificates \ + && wget -qO - https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource-keyring.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/nodesource-keyring.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null \ + && apt-get update && apt-get install -y --no-install-recommends nodejs \ + && npm install -g gplint@2.3.0 \ + && cp /etc/skel/.bashrc /root/.bashrc + +# Install bats +RUN batstmp="$(mktemp -d /tmp/bats-core-${BATS_VERSION}.XXXX)" \ + && wget -qO - "https://github.com/bats-core/bats-core/archive/refs/tags/v${BATS_VERSION}.tar.gz" | tar xz -C "${batstmp}" \ + && bash "${batstmp}/bats-core-${BATS_VERSION}/install.sh" /usr/local \ + && rm -rf "${batstmp}" \ + && git -C /usr/local clone -b v0.3.0 https://github.com/bats-core/bats-support.git \ + && git -C /usr/local clone -b v2.1.0 https://github.com/bats-core/bats-assert.git diff --git a/.devcontainer/gherkin/apt-requirements-base.json b/.devcontainer/gherkin/apt-requirements-base.json new file mode 100644 index 00000000..90e34734 --- /dev/null +++ b/.devcontainer/gherkin/apt-requirements-base.json @@ -0,0 +1,7 @@ +{ + "bash-completion": "1:2.11-8", + "ca-certificates": "20240203", + "git": "1:2.43.0-1ubuntu7.2", + "gnupg2": "2.4.4-2ubuntu17.2", + "wget": "1.21.4-1ubuntu4.1" +} diff --git a/.devcontainer/gherkin/devcontainer-metadata-vscode.json b/.devcontainer/gherkin/devcontainer-metadata-vscode.json new file mode 100644 index 00000000..10800fb4 --- /dev/null +++ b/.devcontainer/gherkin/devcontainer-metadata-vscode.json @@ -0,0 +1,14 @@ +{ + "remoteEnv": { + "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" + }, + "customizations": { + "vscode": { + "extensions": [ + "mhutchie.git-graph@1.30.0", + "ms-vsliveshare.vsliveshare@1.0.5948", + "usernamehw.errorlens@3.26.0" + ] + } + } +} diff --git a/.devcontainer/gherkin/devcontainer.json b/.devcontainer/gherkin/devcontainer.json new file mode 100644 index 00000000..da2583cc --- /dev/null +++ b/.devcontainer/gherkin/devcontainer.json @@ -0,0 +1,26 @@ +{ + "build": { + "dockerfile": "Dockerfile", + "context": "../.." + }, + "remoteEnv": { + "CONTAINER_FLAVOR": "gherkin" + }, + "customizations": { + "vscode": { + "settings": { + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true + }, + "extensions": [ + "github.copilot@1.208.0", + "github.vscode-github-actions@0.26.3", + "github.vscode-pull-request-github@0.90.0", + "jetmartin.bats@0.1.10", + "mhutchie.git-graph@1.30.0", + "sonarsource.sonarlint-vscode@4.7.0", + "usernamehw.errorlens@3.20.0" + ] + } + } +} diff --git a/.github/workflows/pr-image-cleanup.yml b/.github/workflows/pr-image-cleanup.yml index bde1c229..af40dea1 100644 --- a/.github/workflows/pr-image-cleanup.yml +++ b/.github/workflows/pr-image-cleanup.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - flavor: ["cpp", "rust"] + flavor: [cpp, gherkin, rust] permissions: packages: write steps: diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index c6260aaf..fc63a53c 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -59,7 +59,7 @@ jobs: update-release-notes: strategy: matrix: - flavor: [cpp, rust] + flavor: [cpp, gherkin, rust] runs-on: ubuntu-latest permissions: contents: write diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index fd38753f..69ba59f0 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - flavor: ["cpp", "rust"] + flavor: [cpp, gherkin, rust] # Using our own container is required since we need all package sources # set-up correctly. container: ghcr.io/philips-software/amp-devcontainer-${{ matrix.flavor }}:edge @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - flavor: ["cpp", "rust"] + flavor: [cpp, gherkin, rust] permissions: contents: write pull-requests: write diff --git a/.github/workflows/vulnerability-scan.yml b/.github/workflows/vulnerability-scan.yml index 194cc977..e3629e06 100644 --- a/.github/workflows/vulnerability-scan.yml +++ b/.github/workflows/vulnerability-scan.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - flavor: ["cpp", "rust"] + flavor: [cpp, gherkin, rust] permissions: security-events: write steps: diff --git a/.github/workflows/wc-build-push-test.yml b/.github/workflows/wc-build-push-test.yml index 19ae94ca..4889312e 100644 --- a/.github/workflows/wc-build-push-test.yml +++ b/.github/workflows/wc-build-push-test.yml @@ -25,7 +25,7 @@ jobs: build-push: strategy: matrix: - flavor: [cpp, rust] + flavor: [cpp, gherkin, rust] uses: ./.github/workflows/wc-build-push.yml permissions: actions: read @@ -61,7 +61,7 @@ jobs: integration-test: strategy: matrix: - flavor: [cpp, rust] + flavor: [cpp, gherkin, rust] runner: ["ubuntu-latest", "ubuntu-24.04-arm"] needs: build-push uses: ./.github/workflows/wc-integration-test.yml diff --git a/README.md b/README.md index 2e2a0bfb..2939c011 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This repository contains [devcontainers](https://docs.github.com/en/codespaces/s - **Batteries Included** 🔋: Pre-configured tools for local development and continuous integration. - **Multi-platform Support** ⚙️: Compatible with x64 and arm64 hardware on Windows, Linux, and macOS. -- **Image Flavors** 🍨: Dedicated containers for C++ and Rust development. +- **Image Flavors** 🍨: Dedicated containers for C++, Gherkin and Rust development. - **IDE Integration** 💻: Fully compatible with GitHub Codespaces and VS Code. - **Semantic Versioning** 🔢: Clear versioning strategy for container images. - **Secure** 🔒: Emphasis on supply-chain security and compatible with Dependabot. @@ -51,9 +51,10 @@ This repository is under active development; see [pulse](https://github.com/phil The following devcontainers are published towards the [GitHub Container Registry](https://ghcr.io/): - [amp-devcontainer-cpp](https://github.com/orgs/philips-software/packages/container/package/amp-devcontainer-cpp); the C++ container +- [amp-devcontainer-gherkin](https://github.com/orgs/philips-software/packages/container/package/amp-devcontainer-gherkin); the Gherkin container - [amp-devcontainer-rust](https://github.com/orgs/philips-software/packages/container/package/amp-devcontainer-rust); the Rust container -Both containers include a full [Visual Studio Code](https://code.visualstudio.com/) configuration that is compatible with [GitHub Codespaces](https://github.com/features/codespaces). +All containers include a full [Visual Studio Code](https://code.visualstudio.com/) configuration that is compatible with [GitHub Codespaces](https://github.com/features/codespaces). A summary of the included tools can be found below. For the full list of all included tools and tool versions see the [Dependency Graph](https://github.com/philips-software/amp-devcontainer/network/dependencies), the SBOM published with a [release](https://github.com/philips-software/amp-devcontainer/releases), or the SBOM attached to the image. @@ -65,6 +66,10 @@ Next to the compilers there is support for package management (using [CPM.cmake] The default build system is set up to use CMake, Ninja and CCache. +#### amp-devcontainer-gherkin + +The amp-devcontainer-cpp built from this repository contains tools for authoring Gherkin feature files. + #### amp-devcontainer-rust The amp-devcontainer-rust built from this repository contains the Rust ecosystem and additional tools to facilitate, embedded, Rust development. @@ -132,6 +137,12 @@ The attestations can be checked with the following command, verifying that the i gh attestation verify --repo philips-software/amp-devcontainer oci://ghcr.io/philips-software/amp-devcontainer-cpp ``` +> amp-devcontainer-gherkin + +```sh +gh attestation verify --repo philips-software/amp-devcontainer oci://ghcr.io/philips-software/amp-devcontainer-gherkin +``` + > amp-devcontainer-rust ```sh @@ -146,23 +157,11 @@ The resulting containers can be used in a `.devcontainer.json` file or in a `.de > While the following examples use the `latest` tag, it is recommended to pin to a specific version. Or better yet, a specific SHA. > See the [releases](https://github.com/philips-software/amp-devcontainer/releases) for the SHA corresponding to a specific release. -#### amp-devcontainer-cpp - -> .devcontainer/devcontainer.json or .devcontainer.json - -```json -{ - "image": "ghcr.io/philips-software/amp-devcontainer-cpp:latest" -} -``` - -#### amp-devcontainer-rust - > .devcontainer/devcontainer.json or .devcontainer.json ```json { - "image": "ghcr.io/philips-software/amp-devcontainer-rust:latest" + "image": "ghcr.io/philips-software/amp-devcontainer-:latest" } ``` diff --git a/test/gherkin/integration-tests.bats b/test/gherkin/integration-tests.bats new file mode 100644 index 00000000..0fcb5e31 --- /dev/null +++ b/test/gherkin/integration-tests.bats @@ -0,0 +1,18 @@ +#!/usr/bin/env bats + +bats_require_minimum_version 1.5.0 + +setup() { + load '/usr/local/bats-support/load' + load '/usr/local/bats-assert/load' + + pushd ${BATS_TEST_DIRNAME}/workspace +} + +teardown() { + popd +} + +@test "gherkin tests should start" { + ls -la +} diff --git a/test/gherkin/workspace/test-scenario.feature b/test/gherkin/workspace/test-scenario.feature new file mode 100644 index 00000000..94bed824 --- /dev/null +++ b/test/gherkin/workspace/test-scenario.feature @@ -0,0 +1,60 @@ +Feature: Shopping Cart Functionality + As an online shopper + I want to manage items in my shopping cart + So that I can purchase the products I need + + Background: + Given the online store is operational + And I am logged in as a registered user + And my shopping cart is empty + + Rule: Users must be logged in to add items to cart + Example: Adding an item to cart as a logged-in user + When I browse to the "Electronics" category + And I select the "Smartphone" product + Then I should see the product details + And the "Add to Cart" button should be enabled + When I click the "Add to Cart" button + Then 1 item should be added to my cart + And I should see a confirmation message + + Rule: Cart total must be calculated correctly + Scenario Outline: Verifying cart calculations with different quantities + Given I have added a "" with price $ to my cart + When I update the quantity to + Then the item subtotal should be $ + And the cart total should include the subtotal + + Examples: + | product | price | quantity | subtotal | + | Headphones | 50.00 | 2 | 100.00 | + | Charger | 25.00 | 3 | 75.00 | + | Case | 15.99 | 1 | 15.99 | + + Rule: Users can adjust quantities of items in cart + Scenario: Increasing item quantity + Given I have added a "Tablet" with price $199.99 to my cart + When I increase the quantity to 2 + Then the cart should contain 2 "Tablet" items + And the item subtotal should be $399.98 + + Scenario: Removing an item from the cart + Given I have added a "Laptop" with price $899.99 to my cart + When I click the "Remove" button for this item + Then the item should be removed from my cart + And my cart should be empty + But the item should be available for future purchase + + Rule: Checkout process requires valid payment information + @critical @payment + Scenario: Proceeding to checkout with valid payment details + Given I have added a "Monitor" with price $249.99 to my cart + And I have proceeded to the checkout page + When I enter valid shipping information + And I enter valid payment details + | Card Type | Card Number | Expiry Date | CVV | + | Visa | 4111111111111111 | 12/25 | 123 | + And I confirm the order + Then I should see an order confirmation + And I should receive an email receipt + * My cart should be empty after purchase