Dashboard filters - Add due date filter #1487
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: Partaj CI | |
on: | |
push: | |
branches: [ main, production ] | |
pull_request: | |
branches: [ main ] | |
env: | |
DJANGO_CONFIGURATION: "Test" | |
DJANGO_PARTAJ_PRIMARY_LOCATION: "https://partaj" | |
DJANGO_SECRET_KEY: "TestSecretKey" | |
DJANGO_SETTINGS_MODULE: "partaj.settings" | |
DJANGO_SUPERUSER_USERNAME: "admin" | |
DJANGO_SUPERUSER_EMAIL: "admin@example.com" | |
DJANGO_SUPERUSER_PASSWORD: "admin" | |
jobs: | |
################ | |
# BACKEND JOBS # | |
################ | |
lint-back-black: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/backend | |
container: python:3.9.16 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install system dependencies | |
run: apt-get update && apt-get install -y gettext | |
- name: Install python dependencies | |
run: pip install .[dev] | |
- name: Run black in check mode | |
run: black --check partaj | |
lint-back-flake8: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/backend | |
container: python:3.9.16 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install system dependencies | |
run: apt-get update && apt-get install -y gettext | |
- name: Install python dependencies | |
run: pip install .[dev] | |
- name: Run flake8 | |
run: flake8 | |
lint-back-pylint: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/backend | |
container: python:3.9.16 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install system dependencies | |
run: apt-get update && apt-get install -y gettext | |
- name: Install python dependencies | |
run: pip install .[dev] | |
- name: Run pylint | |
run: pylint --rcfile=.pylintrc partaj | |
lint-back-isort: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/backend | |
container: python:3.9.16 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install system dependencies | |
run: apt-get update && apt-get install -y gettext | |
- name: Install python dependencies | |
run: pip install .[dev] | |
- name: Run isort in check mode | |
run: isort --check-only partaj | |
test-back: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/backend | |
container: python:3.9.16 | |
services: | |
postgres: | |
image: postgres:12.1 | |
env: | |
POSTGRES_DB: partaj | |
POSTGRES_PASSWORD: admin | |
POSTGRES_USER: admin | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
elasticsearch: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 | |
env: | |
discovery.type: single-node | |
options: >- | |
--health-cmd "curl http://localhost:9200/_cluster/health" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 10 | |
ports: | |
# <port on host>:<port on container> | |
- 9200:9200 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install system dependencies | |
run: apt-get update && apt-get install -y gettext | |
- name: Install python dependencies | |
run: pip install .[dev] | |
- name: Get translations | |
run: python manage.py compilemessages | |
- name: Run our test suite | |
run: pytest | |
env: | |
POSTGRES_HOST: postgres | |
################# | |
# FRONTEND JOBS # | |
################# | |
build-front: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/frontend | |
container: node:22.4.0 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
### CACHE ### | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Restore yarn cache | |
uses: actions/cache@v1 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn | |
### END CACHE ### | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build with Typescript | |
run: yarn build | |
lint-front-prettier: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/frontend | |
container: node:22.4.0 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
### CACHE ### | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Restore yarn cache | |
uses: actions/cache@v1 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
### END CACHE ### | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Run prettier as a linter | |
run: yarn prettier --list-different "js/**/*.+(ts|tsx|json|js|jsx)" "*.+(ts|tsx|json|js|jsx)" | |
test-front: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/frontend | |
container: node:22.4.0 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
### CACHE ### | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Restore yarn cache | |
uses: actions/cache@v1 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
### END CACHE ### | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Run tests | |
run: yarn test | |
############## | |
# DEPLOYMENT # | |
############## | |
deploy: | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/production' | |
needs: [lint-back-black, lint-back-flake8, lint-back-pylint, lint-back-isort, test-back, build-front, lint-front-prettier, test-front] | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./ | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install system dependencies | |
run: sudo apt-get update && sudo apt-get install -y gettext | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v1.4.4 | |
with: | |
node-version: '14' | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9.16' | |
### CACHE ### | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Restore yarn cache | |
uses: actions/cache@v1 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
### END CACHE ### | |
- name: Install frontend deps & run the build | |
run: | | |
cd src/frontend | |
yarn install --frozen-lockfile | |
yarn build | |
yarn build-css | |
- name: Generate binary localization files for backend strings | |
run: | | |
cd src/backend | |
pip install .[dev] | |
python manage.py compilemessages | |
- name: Create the deployment directory and copy the Partaj git repository there | |
run: | | |
mkdir ../deployment | |
cp -R .git ../deployment | |
- name: Checkout the deployment branch (before copying files to avoid conflicts) | |
run: | | |
cd ../deployment | |
git fetch | |
git checkout ${{ github.ref == 'refs/heads/production' && 'deployment-production' || 'deployment-staging' }} | |
- name: Copy the actual Partaj source files (and frontend build results) to the deployment directory | |
run: | | |
rm -rf ../deployment/* | |
cp -R src/backend/* ../deployment | |
cp docker/files/usr/local/etc/gunicorn/partaj.py ../deployment/partaj-gunicorn.py | |
- name: Generate a requirements.txt file from setup.cfg | |
run: python requirements.py | |
- name: Deploy the build artifact to Scalingo | |
run: | | |
cd ../deployment | |
git config user.email "contact.partaj@ecologie.gouv.fr" | |
git config user.name "Partaj Bot" | |
git add --all | |
git commit --allow-empty -m "Deploy to ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }}" | |
git push origin ${{ github.ref == 'refs/heads/production' && 'deployment-production' || 'deployment-staging' }} |