diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..460710c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,24 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + + - package-ecosystem: "pip" + directory: "backend/" # Location of package manifests + schedule: + interval: "weekly" + ignore: + - dependency-name: "django" + update-types: [ "version-update:semver-major", "version-update:semver-minor" ] # only allow auto update on django bug and security fixes + + - package-ecosystem: "npm" + directory: "front-end/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..c3cef6b --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,22 @@ +changelog: + categories: + - title: ๐ŸŽ‰ Features + labels: + - '*' + exclude: + labels: + - dependencies + - Bug + - documentation + + - title: ๐Ÿ›  Bug fixes + labels: + - 'Bug' + + - title: ๐Ÿ“˜ Documentation + labels: + - documentation + + - title: โคด Dependencies + labels: + - dependencies diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..4862cdc --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,116 @@ +name: Quality checks + +on: + pull_request: + push: + branches: + - master + - main + - next + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DEBIAN_FRONTEND: noninteractive + +jobs: + flake8: + name: Python Flake8 check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version-file: ./backend/.python-version + + - name: Install flake8 + working-directory: ./backend + run: | + pip install flake8 -c dev-requirements.txt + + - name: Flake8 + working-directory: ./backend + run: | + flake8 project + + isort: + name: Python iSort check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version-file: ./backend/.python-version + + - name: Install isort + working-directory: ./backend + run: | + pip install isort -c dev-requirements.txt + + - name: iSort + working-directory: ./backend + run: | + isort -c project + + black: + name: Python Black check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version-file: ./backend/.python-version + + - name: Install black + working-directory: ./backend + run: | + pip install black -c dev-requirements.txt + + - name: black + working-directory: ./backend + run: | + black --check project + + prettier: + name: JS Prettier check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ./front-end/.nvmrc + cache: 'npm' + cache-dependency-path: ./front-end/.nvmrc + + - name: Install node dependencies + working-directory: ./front-end + run: | + npm ci --no-audit + + - name: Prettier check + working-directory: ./front-end + run: | + npm run format:check + + type: + name: JS Type check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ./front-end/.nvmrc + cache: 'npm' + cache-dependency-path: ./front-end/.nvmrc + + - name: Install node dependencies + working-directory: ./front-end + run: | + npm ci --no-audit + + - name: Type check + working-directory: ./front-end + run: | + npm run type:check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b5880b1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,124 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + - main + - next + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + DEBIAN_FRONTEND: noninteractive + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + CI: false + +jobs: + python-unittests: + name: Python Unit tests + runs-on: ubuntu-latest + env: + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_HOST: 127.0.0.1 + + services: + postgres: + image: postgis/postgis:16-3.4 + env: + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + ports: + - 5432:5432 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version-file: ./backend/.python-version + cache: 'pip' + cache-dependency-path: | + ./backend/requirements.txt + ./backend/dev-requirements.txt + + - name: Install system libraries + working-directory: ./backend + run: | + sudo apt-get -qq update + sudo apt-get -qq install -y libpq-dev gdal-bin gettext + + - name: Install dependencies + working-directory: ./backend + run: | + pip install -r requirements.txt -r dev-requirements.txt + + - name: Run django unit tests + working-directory: ./backend + run: | + coverage run --parallel-mode --concurrency=multiprocessing ./manage.py test --parallel -v 3 + coverage combine + coverage xml -o coverage.xml + + - uses: codecov/codecov-action@v4 + with: + files: ./backend/coverage.xml + flags: python-unittests + token: ${{ secrets.CODECOV_TOKEN }} + + js-build: + name: JS tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: ./front-end/.nvmrc + cache: 'npm' + cache-dependency-path: ./front-end/.nvmrc + + - name: Install node dependencies + working-directory: ./front-end + run: | + npm ci --no-audit + + - name: npm build + working-directory: ./front-end + run: | + npm run build + + docker-build: + name: Docker build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: .docker/Dockerfile + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: prod + diff --git a/front-end/.nvmrc b/front-end/.nvmrc new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/front-end/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/front-end/package.json b/front-end/package.json index 5e6e1e6..e8a2e71 100644 --- a/front-end/package.json +++ b/front-end/package.json @@ -2,6 +2,9 @@ "name": "regard-d-altitude", "version": "0.0.0", "scripts": { + "type:check": "tsc --noEmit", + "format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache", + "format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache", "ng": "ng", "start": "ng serve", "build": "ng build",