I'm working on a dashboard web app and I would like to use Github actions to deploy and test it. I've successfully written a workflow to build and push the docker image but I'm experiencing issues to test it.
It is a Vue 2 app that listens on port 8080 the tests are executed with Cypress. My workflow uses docker-compose to build it for production and serves it via nginx. Of course, it works for production on my company servers.
When deploying it via Github Actions, nginx execution and build-stage act as normal and the app should be up and running but when running my tests, Cypress throws an ECONNREFUSED on http://127.0.0.1:8080 like if github was preventing my app from listening to this port or that it is running in an external container.
I assume there has to be a way to run & test a web server on Github Actions but I could not find it in the docs or on a forum.
Does anyone knows how to achieve this ?
Here is a commented version of my .yml github workflow
name: Build and test
# event listener to trigger the workflow
on:
push:
branches:
- 'workflows-dev'
- 'master'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # Checkout into the repo
- run: sed -i -e "s/http\:\/\/<STRAPI_URL>/${{ secrets.PREPROD_URL }}/" Dockerfile
- run: docker build -t dashboard:${{ github.run_id }}-test . # Build docker image with a unique tag
- run: docker run dashboard:${{ github.run_id }}-test & # Runs it as a demon job '&'
- run: sleep 60 # Sleeping to let the server actually start up before testing
- run: |
echo {\"site\": \"http://127.0.0.1:8080\", \"identifier\": \"${{ secrets.PREPROD_USER }}\", \"password\": \"${{ secrets.PREPROD_PASSWORD }}\"} > tests/cypress.env.json # Setup ENV variables for the tests
- run: npm test