diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml new file mode 100644 index 0000000..e11bb12 --- /dev/null +++ b/.github/workflows/backend-ci.yml @@ -0,0 +1,73 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Backend CI + +on: + push: + branches: [ "develop", "main" ] + pull_request: + branches: [ "develop" ] + +permissions: + contents: read + +jobs: + lint: + name: Lint Python Code (PEP8) + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + cd server + python -m pip install --upgrade pip + pip install flake8 black + - name: Run flake8 (Linting) + run: | + cd server + flake8 src/ tests/ + - name: Run Black (Formatting Check) + run: | + cd server + black --check --diff src/ tests/ + test: + name: Run Backend Tests + runs-on: ubuntu-latest + needs: lint # Ensures linting passes before running tests + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + cd server + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Create .env file in CI + run: | + cd server + touch .env + echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> .env + echo "SUPABASE_URL=${{ secrets.SUPABASE_KEY }}" >> .env + echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" >> .env + + - name: Run Tests + run: | + cd server + pytest tests/ --ignore=tests/test_database_connection.py diff --git a/server/src/luas_api.py b/server/src/luas_api.py index 9ccd52a..01bf48f 100644 --- a/server/src/luas_api.py +++ b/server/src/luas_api.py @@ -68,8 +68,8 @@ def get(self, stop): while True: stop = str( input( - 'Enter stop code to see live arrivals and departures,' - 'or "exit" to leave: ' + "Enter stop code to see live arrivals and departures," + ' or "exit" to leave: ' ) ) if stop == "exit":