ci: add docker compose testing workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker compose testing | |
on: | |
push: | |
branches-ignore: | |
- main | |
workflow_dispatch: # Allows manual triggering of the workflow | |
jobs: | |
automated-api-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
environment: | |
- ./postman/docker.postman_environment.json | |
config: | |
- { | |
collection: ./postman/Postman Collections/Issuance-Presentation Tests.postman_collection.json, | |
dataset: ./postman/Datasets/Issuance-Presentation Tests.postman_collection.csv | |
} | |
steps: | |
- name: Get dataset filename | |
run: | | |
path="${{ matrix.config.dataset }}" | |
filenameWithExtension="${path##*/}" | |
filenameNoExtension=${filenameWithExtension%.*} | |
echo "Will use filename $filenameNoExtension for reports" | |
echo "dataset_filename=$filenameNoExtension" >> $GITHUB_ENV | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Checkout waltid-identity-postman | |
uses: actions/checkout@v4 | |
with: | |
repository: walt-id/waltid-identity-postman | |
ref: main | |
token: ${{ secrets.PAT }} | |
path: "./postman" | |
- name: Install Docker using Docker's official script | |
run: | | |
# Add Docker's official GPG key: | |
sudo apt-get update | |
sudo apt-get install ca-certificates curl | |
sudo install -m 0755 -d /etc/apt/keyrings | |
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
sudo chmod a+r /etc/apt/keyrings/docker.asc | |
# Add the repository to Apt sources: | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
continue-on-error: false | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.32.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version | |
continue-on-error: false | |
- name: Run stack | |
run: docker compose -f ./docker-compose/docker-compose.yaml up --build -d | |
- name: Ping services | |
timeout-minutes: 5 | |
run: | | |
chmod +x ./ping.sh | |
./ping.sh | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install newman | |
run: "npm install -g newman newman-reporter-htmlextra" | |
- name: Add docker to /etc/hosts | |
run: | | |
sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts | |
- name: Run API tests | |
env: | |
NODE_OPTIONS: "--max-old-space-size=6144 --max-semi-space-size=1024" | |
run: | | |
newman run "${{ matrix.config.collection }}" \ | |
--environment "${{ matrix.environment }}" \ | |
--iteration-data "${{ matrix.config.dataset }}" \ | |
--reporters htmlextra,cli,emojitrain \ | |
--reporter-cli-show-timestamps \ | |
--reporter-htmlextra-export ./reports/${{ env.dataset_filename }}.html \ | |
--insecure \ | |
--verbose | |
- name: Upload report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: reports | |
path: ./reports | |
overwrite: true | |
retention-days: 5 |