Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
omarlopesino committed May 27, 2024
0 parents commit fda0358
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: tests
on:
pull_request:
push:
branches: [ main ]

schedule:
- cron: '25 08 * * *'

workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: Debug with tmate
required: false
default: false

# This is required for "gautamkrishnar/keepalive-workflow", see "ddev/github-action-add-on-test"
permissions:
actions: write

jobs:
tests:
strategy:
matrix:
ddev_version: [stable, HEAD]
fail-fast: false

runs-on: ubuntu-latest

steps:
- uses: ddev/github-action-add-on-test@v2
with:
ddev_version: ${{ matrix.ddev_version }}
token: ${{ secrets.GITHUB_TOKEN }}
debug_enabled: ${{ github.event.inputs.debug_enabled }}
addon_repository: ${{ env.GITHUB_REPOSITORY }}
addon_ref: ${{ env.GITHUB_REF }}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# DDEV newman

Allows running newman on ddev setups.

## Installation

Install this addon by running:

```
ddev get metadrop/ddev-newman
```

## Usage

TBD
7 changes: 7 additions & 0 deletions commands/newman/newman
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

## Description: Run newman
## Usage: newman [args]
## Example: "ddev newman my_collection.json -e environment.json
## ExecRaw: true
newman "$@"
19 changes: 19 additions & 0 deletions docker-compose.newman.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
newman:
command: sleep infinity
container_name: "ddev-${DDEV_SITENAME}-newman"
build:
context: ./newman
args:
BASE_IMAGE: postman/newman:6-ubuntu
username: $USER
uid: $DDEV_UID
gid: $DDEV_GID
entrypoint: []
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: ${DDEV_APPROOT}
volumes:
- ../:/etc/newman
- .:/mnt/ddev_config:ro
- ddev-global-cache:/mnt/ddev-global-cache
7 changes: 7 additions & 0 deletions install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: ddev-newman
project_files:
- docker-compose.newman.yaml
- ./newman
- ./commands/newman/newman
post_install_actions:
- echo "Newman has been added successfully."
14 changes: 14 additions & 0 deletions newman/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE


# Swap to root user.
USER root

# Add ddev user.
ARG username
ARG uid
ARG gid
RUN (groupadd --gid $gid "$username" || groupadd "$username" || true) && (useradd -l -m -s "/bin/bash" --gid "$username" --comment '' --uid $uid "$username" || useradd -l -m -s "/bin/bash" --gid "$username" --comment '' "$username" || useradd -l -m -s "/bin/bash" --gid "$gid" --comment '' "$username" || useradd -l -m -s "/bin/bash" --comment '' $username )

USER $username
43 changes: 43 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
setup() {
set -eu -o pipefail
export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.."
export TESTDIR=~/tmp/test-addon-template
mkdir -p $TESTDIR
export PROJNAME=test-addon-template
export DDEV_NON_INTERACTIVE=true
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true
cd "${TESTDIR}"
ddev config --project-name=${PROJNAME}
ddev start -y >/dev/null
}

health_checks() {
output=$(ddev exec -s newman newman --version)
# Check if the output contains "Healthcheck passed!"
[[ $? == 0 ]]
}

teardown() {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1
[ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR}
}

@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev restart
health_checks
}

@test "install from release" {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
echo "# ddev get Metadrop/ddev-newman with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get Metadrop/ddev-newman
ddev restart >/dev/null
health_checks
}
Empty file added tests/testdata/.gitmanaged
Empty file.

0 comments on commit fda0358

Please sign in to comment.