Skip to content

Commit

Permalink
Switch testing to httpyac
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Oct 9, 2024
1 parent a927742 commit b0afb80
Show file tree
Hide file tree
Showing 7 changed files with 2,096 additions and 1,604 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@ jobs:
- name: 'Run linting'
run: make lint

- name: 'Run service'
run: make run &

- name: 'Run tests'
run: make test-report
run: |
sleep 10
make test-report
- name: 'Upload test results'
uses: actions/upload-artifact@v2
# Disabled when running locally with the nektos/act tool
if: ${{ always() }}
- name: 'Test reporting'
uses: phoenix-actions/test-reporting@v8
id: test-report
if: success() || failure()
with:
name: test-results
path: ./src/mochawesome-report
name: Unit Test Report
path: src/test-results.xml
reporter: java-junit
fail-on-error: false

build:
name: 'Build & Push Image'
name: 'Build & push image'
needs: test
runs-on: ubuntu-latest
steps:
Expand All @@ -59,10 +66,10 @@ jobs:
echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REG -u $GITHUB_ACTOR --password-stdin
make push
- name: 'Trigger AKS release pipeline'
if: github.ref == 'refs/heads/master'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: 'CD Release - AKS'
token: ${{ secrets.GH_PAT }}
inputs: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }'
# - name: 'Trigger AKS release pipeline'
# if: github.ref == 'refs/heads/master'
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: 'CD Release - AKS'
# token: ${{ secrets.GH_PAT }}
# inputs: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }'
17 changes: 8 additions & 9 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ AZURE_RES_GROUP ?= demoapps
AZURE_REGION ?= northeurope
AZURE_APP_NAME ?= nodejs-demoapp

# Used by `test-api` target
TEST_HOST ?= localhost:3000
# Used by test targets
TEST_BASE_URL ?= http://localhost:3000
TESTS_GLOB ?= base-tests.http

# Don't change
SRC_DIR := src

.EXPORT_ALL_VARIABLES:
.PHONY: help lint lint-fix image push run deploy undeploy clean test test-api test-report .EXPORT_ALL_VARIABLES
.DEFAULT_GOAL := help

Expand Down Expand Up @@ -48,15 +50,12 @@ undeploy: ## 💀 Remove from Azure
@echo "### WARNING! Going to delete $(AZURE_RES_GROUP) 😲"
az group delete -n $(AZURE_RES_GROUP) -o table --no-wait

test: $(SRC_DIR)/node_modules ## 🎯 Unit tests with Mocha
cd $(SRC_DIR); npm run test
test: $(SRC_DIR)/node_modules ## 🚦 Run integration tests, server must be running
$(SRC_DIR)/node_modules/.bin/httpyac $(SRC_DIR)/tests/$(TESTS_GLOB) --all --output short --var baseUrl=$(TEST_BASE_URL)

test-report: $(SRC_DIR)/node_modules ## 🤡 Unit tests with Mocha & mochawesome report
test-report: $(SRC_DIR)/node_modules ## 🤡 Tests but with JUnit output, server must be running
rm -rf $(SRC_DIR)/test-results.*
cd $(SRC_DIR); npm run test-report

test-api: $(SRC_DIR)/node_modules .EXPORT_ALL_VARIABLES ## 🚦 Run integration API tests, server must be running
cd $(SRC_DIR); npm run test-postman
$(SRC_DIR)/node_modules/.bin/httpyac $(SRC_DIR)/tests/$(TESTS_GLOB) --all --junit > test-results.xml

clean: ## 🧹 Clean up project
rm -rf $(SRC_DIR)/node_modules
Expand Down
Loading

0 comments on commit b0afb80

Please sign in to comment.