Backend CI #57
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend CI | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Automatically on push to main, test-workflow-implementation or dev | |
# And on pull request to main or dev | |
# Add more branches by separating with comma | |
push: | |
branches: [ "main", "tests-workflow-implementation", "dev" ] | |
pull_request: | |
branches: [ "main", "dev" ] | |
jobs: | |
Test-Backend-App: | |
runs-on: ubuntu-latest | |
#Environment used to access secrets | |
#environment: ENVIRONMENT_NAME_GOES_HERE | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout Branch | |
uses: actions/checkout@v3 | |
# Creates a .env file with the variables succeeding envkey_ | |
# i.e: envkey_PORT: 8080 | |
# creates: PORT=8080 | |
# in the directory backend-app/ | |
- name: Create .env file | |
uses: SpicyPizza/create-envfile@v1.3.0 | |
with: | |
envkey_PORT: 8080 | |
envkey_RUN_OCPP_TEST: 0 | |
envkey_USE_LOCAL_DATABASE: 1 | |
envkey_OCPP_TEST_INTERVAL_MULTIPLIER: 1 | |
envkey_BYPASS_KLARNA: 1 | |
envkey_LIVEMETRICS_DB_UPDATE_INTERVAL: 10000 | |
envkey_AWS_REGION: ${{ secrets.AWS_REGION }} | |
envkey_USER_POOL: ${{ secrets.USER_POOL }} | |
envkey_USER_POOL_ID: ${{ secrets.USER_POOL_ID }} | |
envkey_USER_POOL_SECRET: ${{ secrets.USER_POOL_SECRET }} | |
envkey_DATABASE_NAME: "UNNEEDED" | |
envkey_DATABASE_USERNAME: "UNNEEDED" | |
envkey_DATABASE_PASSWORD: "UNNEEDED" | |
envkey_DATABASE_HOST: "UNNEEDED" | |
envkey_KLARNA_TOKEN: ${{ secrets.KLARNA_TOKEN }} | |
directory: backend-app/ | |
# Run the backend app | |
# & is used to signal that this task will keep running, as to not get stuck on this step | |
- name: launch docker container | |
run: | | |
docker-compose build | |
docker-compose up & | |
# Runs sequentially to starting the back-end app | |
- name: Install requirements | |
# Installs the requirements | |
run: | | |
export PYTHONPATH=. | |
pip install -r ./test/requirements.txt | |
# Executes the tests within the /backend_tests folder | |
# - name: Run PyTest | |
# run: python -m pytest ./test/backend_tests --junit-xml=report.xml | |
- name: Install Jest | |
run: | | |
npm i jest | |
npm i jest-junit | |
- name: Install axios | |
run: | | |
npm i axios | |
- name: Run unit tests | |
run: | |
npm test --prefix ./backend-app | |
# Displays a summary and overlook of test cases | |
- name: Publish test result | |
uses: mikepenz/action-junit-report@v3 | |
if: always() # always run even if the previous step fails | |
with: | |
report_paths: '**/*.xml' |