Commit ac3e032f authored by Vegard Murvold Sporstøl's avatar Vegard Murvold Sporstøl
Browse files


parent 40698323
Pipeline #117112 failed with stages
in 2 minutes and 35 seconds
......@@ -126,3 +126,97 @@ If you want to run this as a mobile application
It's possible you will need to add the platforms you want to run and build.
The following documentation can be used to run the application in an Android emulator: \
## Continuous integration
WARNING: Do not perform penetration testing on Heroku applications
Continuous integration will build the code pushed to master and push it to your heroku app so you get a live version of your latest code by just pushing your code to GitLab.
1. Create a heroku account and an app for both the frontend and the backend.
2. Select buildpacks for the two apps. The backend uses Python while the frontend uses node.js.
* Settings > Buildpacks > Add buildpack
* Both applications need the buildpack too.
3. Set the project in the .gitlab-cs.yml file by replacing `<Your-herokuproject-name>` with the name of the Heroku app you created
`- dpl --provider=heroku --app=<Your-herokuproject-name> --api-key=$HEROKU_STAGING_API_KEY`
5. Set varibles at GitLab
* settings > ci > Environment Variables
* `HEROKU_STAGING_API_KEY` = heroku > Account Settings > API Key
6. Add heroku database for the backend
* Resources > Add ons > search for postgres > add "Heroku Postgres"
7. Set variables for the backend on Heroku. Settings > Config vars > Reveal vars
* `DATABASE_URL` = Should be set by default. If not here is where you can find it: Resources > postgress > settings > view credentials > URI
* `PROCFILE` = `backend/secfit/Procfile`
8. Set variables for the frontend on heroku. Settings > Config vars > Reveal vars. Insert the URL for your backend app.
* `PROCFILE` = `frontend/Procfile`
9. Push the repository to both of the heroku applications
* git push `<backend-repository>` HEAD:master
* git push `<frontend-repository>` HEAD:master
10. On GitLab go to CI / CD in the repository menu and select `Run Pipeline` if it has not already started. When both stages complete the app should be available on heroku. Staging will fail from timeout as Heroku does not give the propper response to end the job. But the log should state that the app was deployed.
11. Setup the applications database.
* Install heroku CLI by following:
* Log in to the Heroku CLI by entering `heroku login`. This opens a webbrowser and you accept the login request.
* Migrate database by entering
`heroku run python backend/secfit/ migrate -a <heroku-app-name>`. `Heroku run` will run the folowing command on your heroku instance. Remember to replace `<heroku-app-name>` with your app name
* and create an admin account by running
`heroku run python backend/secfit/ createsuperuser -a <heroku-app-name>`.
* seed database `heroku run python backend/secfit/ loaddata seed.json -a <heroku-app-name>`
12. On the frontend app, add a config variable for `BACKEND_HOST` = `BACKEND_HOST`
You will also need the heroku multi-procfile buildpack:
In general, for this application to work (beyond locally), you will need to set the BACKEND_HOST to the URL of the REST API backend.
## Testing
### **Frontend**
Frontend is tested with Testcafe [](
And is included in the CI/CD as its own stage (test-frontend) in the gitlab-ci.yml file.
#### Prerequisites:
Testcafe, which can be downloaded using npm:
`npm install -g testcafe`
#### Run:
`testcafe chrome frontend-test.js --skip-js-errors`
#### Structure
All frontend tests can be found in `frontend-test.js` located in the source folder.
- **src/**
- **frontend-test.js**
- Test login
- Test statistics (UC-2)
- Test sort exercises (UC-3)
### **Backend**
Backend is tested with the django.test framework [](
And is also included in the CI/CD as its own stage (test-backend) in the gitlab-ci.yml file.
#### Run:
`cd backend/secfit`
`python test`
#### Structure:
- **backend/**
- **secfit/**
- **users/**
- ****
- Boundary value test of registration
- UserSerializer test
- 2-way domain testing of registration
- **workouts/**
- ****
- Boundary value test of new workouts
- Test of FR5
- Test create workout for athlete as coach (UC-1)
- Test categorize exercise (UC-4)
- Test permission-classes in workout/permissions
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment