diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 000000000..f38956bd7 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,34 @@ +name: Unit Test +on: + pull_request: + paths: + - '**/*.py' + - '**/*.js' + - '.github/workflows/unittest.yml' + +jobs: + Run-Unit-Test: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Get env File + run: cp ./example.env ./.env + + - name: Build and run Docker containers + run: docker-compose -f docker-compose.yml up --build --detach + + # adding the "-T" flag to tell the docker to run the command without allocating a TTY (interact with a terminal). + - name: Run Python tests + run: docker-compose -f docker-compose.yml exec -T web python manage.py test + + - name: Run JavaScript Tests + run: docker-compose -f docker-compose.yml exec -T web npm run test + + - name: Stop and remove containers + run: docker-compose -f docker-compose.yml down + + - name: Remove Copied Env file + run: rm ./.env