From 0d2c7764d08dc06e4f3ebc96c5a13022151220ec Mon Sep 17 00:00:00 2001 From: Daniel McCormack <52194107+demccormack@users.noreply.github.com> Date: Sat, 14 Oct 2023 23:54:00 +1300 Subject: [PATCH] Create Github action testing backend --- .github/workflows/backend.yml | 34 ++++++++++++++++++++++++++++++++++ .github/workflows/frontend.yml | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/backend.yml diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..029ee49 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,34 @@ +name: Backend + +on: [push, pull_request] + +jobs: + backend: + name: Backend test, lint and format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: 3.11 + - name: Install dependencies + run: | + cd backend + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: End-to-end test + run: | + set -x + cd backend + CORS_ORIGINS='' MEDIA=.. flask --app src/app.py run & + while [[ -z "${DIR_LIST:-}" ]]; do DIR_LIST=$(curl 'http://127.0.0.1:5000/?dir=' || true); done + + echo "$DIR_LIST" | grep '{"name":".gitignore","type":"file","url":"/.gitignore"}' + echo "$DIR_LIST" | grep '{"name":"backend","type":"directory","url":"/backend"}' + - name: Lint + run: | + pylint $(git ls-files '*.py') + - name: Format + run: | + black . --check diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index e38c09b..8d82506 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -8,7 +8,7 @@ permissions: pull-requests: read jobs: - test-lint-and-format: + frontend: name: Frontend test, lint and format runs-on: ubuntu-latest