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

Update README.md

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: \
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html
## 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 https://github.com/heroku/heroku-buildpack-multi-procfile.git 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
* `IS_HEROKU` = `IS_HEROKU`
* `PROCFILE` = `backend/secfit/Procfile`
8. Set variables for the frontend on heroku. Settings > Config vars > Reveal vars. Insert the URL for your backend app.
* `BACKEND_HOST` = `https://<SECFIT_BACKEND>.herokuapp.com`
* `PROCFILE` = `frontend/Procfile`
9. Push the repository to both of the heroku applications https://devcenter.heroku.com/articles/git
* 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: https://devcenter.heroku.com/articles/heroku-cli
* 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/manage.py 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/manage.py createsuperuser -a <heroku-app-name>`.
* seed database `heroku run python backend/secfit/manage.py 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: https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-multi-procfile.
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 [https://devexpress.github.io/testcafe/](https://devexpress.github.io/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 [https://docs.djangoproject.com/en/3.1/topics/testing/](https://docs.djangoproject.com/en/3.1/topics/testing/)
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 manage.py test`
#### Structure:
- **backend/**
- **secfit/**
- **users/**
- **tests.py**
- Boundary value test of registration
- UserSerializer test
- 2-way domain testing of registration
- **workouts/**
- **tests.py**
- 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