Skip to content

Commit

Permalink
Updating GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-uk committed Oct 9, 2024
1 parent 287bc7f commit dc42c71
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: 'Run linting'
run: make lint
Expand All @@ -33,15 +37,15 @@ jobs:

- name: 'Run tests'
run: |
sleep 10
sleep 5
make test-report
- name: 'Test reporting'
uses: phoenix-actions/test-reporting@v8
id: test-report
if: success() || failure()
with:
name: Unit Test Report
name: Integration Test Report
path: test-results.xml
reporter: java-junit
fail-on-error: false
Expand All @@ -50,9 +54,10 @@ jobs:
name: 'Build & push image'
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v4

# Nicer than using github runid, I think, will be picked up automatically by make
- name: 'Create datestamp image tag'
Expand All @@ -63,7 +68,6 @@ jobs:

# Only when pushing to default branch (e.g. master or main), then push image to registry
- name: 'Push to container registry'
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REG -u $GITHUB_ACTOR --password-stdin
make push
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ push 📤 Push container image to registry
run 🏃 Run locally using Node.js
deploy 🚀 Deploy to Azure Container App
undeploy 💀 Remove from Azure
test 🎯 Unit tests with Jest
test-report 🤡 Unit tests with Jest & Junit output
test-api 🚦 Run integration API tests, server must be running
test 🚦 Run integration tests, server must be running
test-report 🤡 Tests but with JUnit output, server must be running
clean 🧹 Clean up project
```

Expand Down Expand Up @@ -93,6 +92,23 @@ A set of GitHub Actions workflows are included for CI / CD. Automated builds for

[![](https://img.shields.io/github/workflow/status/benc-uk/nodejs-demoapp/CI%20Build%20App)](https://github.com/benc-uk/nodejs-demoapp/actions?query=workflow%3A%22CI+Build+App%22) [![](https://img.shields.io/github/workflow/status/benc-uk/nodejs-demoapp/CD%20Release%20-%20AKS?label=release-kubernetes)](https://github.com/benc-uk/nodejs-demoapp/actions?query=workflow%3A%22CD+Release+-+AKS%22)

# Testing

This project uses a HTTP files located in `src/tests/` that can be used a few different ways, you can instal the [VSCode REST CLient](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) or [httpYac](https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac), [httpYac](https://httpyac.github.io/) is preferred as it supports many more features.

You can interactively run & send the requests in the `src/tests` file using these extensions, but the main reason to use _httpYac_, is it has a much richer language & the support of assertions which can turn the request files into integration tests too 👌

For example:

```http
GET http://localhost:8000/info
?? status == 200
?? body contains Memory
```

_httpYac_ has a command line tool for running tests and .http files which forms the basis of the `make test` and `make test-report` makefile targets. It also natively supports .env files, so will load variables from a .env file if one is found.

# Optional Features

The app will start up and run with zero configuration, however the only features that will be available will be the INFO and TOOLS views. The following optional features can be enabled:
Expand Down
2 changes: 1 addition & 1 deletion src/tests/base-tests.http
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
GET {{baseUrl}}/

?? status == 200
?? body contains Ben Coleman
?? body contains Ben ZZZZZZZZZColeman


### Base - Info page
Expand Down
16 changes: 16 additions & 0 deletions src/tests/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### 🧪 Testing

This project uses HTTP files located in `src/tests/` that can be used a few different ways, you can instal the [VSCode REST CLient](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) or [httpYac](https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac), [httpYac](https://httpyac.github.io/) is preferred as it supports many more features.

You can interactively run & send the requests in the `src/tests` file using these extensions, but the main reason to use _httpYac_, is it has a much richer language & the support of assertions which can turn the request files into integration tests too 👌

For example

```http
GET http://localhost:8000/info
?? status == 200
?? body contains Memory
```

_httpYac_ has a command line tool for running tests and .http files which forms the basis of the `make test` and `make test-report` makefile targets. It also natively supports .env files, so will load variables from a .env file if one is found.

0 comments on commit dc42c71

Please sign in to comment.