2021-04-30 11:19:21 +02:00
|
|
|
---
|
2021-08-30 17:11:15 +02:00
|
|
|
name: Validate models.yml, initial-data.json and example-data.json
|
2020-09-19 20:53:44 +02:00
|
|
|
on: [push, pull_request]
|
2021-02-05 17:08:29 +01:00
|
|
|
env:
|
2021-08-04 12:44:39 +02:00
|
|
|
PYTHON_VERSION: 3.9.6
|
2020-09-19 20:53:44 +02:00
|
|
|
jobs:
|
2021-02-05 17:08:29 +01:00
|
|
|
validate-models:
|
2020-09-19 20:53:44 +02:00
|
|
|
name: Validate models.yml
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v2
|
2020-09-19 20:53:44 +02:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
2021-08-04 12:44:39 +02:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Install requirements
|
|
|
|
run: pip install -U -r docs/modelsvalidator/requirements.txt
|
2020-11-11 12:02:23 +01:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Validate models.yml
|
|
|
|
working-directory: docs/modelsvalidator
|
|
|
|
run: python validate.py
|
2021-02-05 17:08:29 +01:00
|
|
|
|
2021-08-18 08:10:31 +02:00
|
|
|
validate-example-data:
|
2021-08-10 18:44:22 +02:00
|
|
|
name: Validate example-data.json
|
2021-02-05 17:08:29 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v2
|
2021-02-05 17:08:29 +01:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Checkout backend submodule
|
|
|
|
run: git submodule update --init openslides-backend/
|
2021-08-04 12:44:39 +02:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
2021-02-05 17:08:29 +01:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: Install requirements
|
|
|
|
run: pip install -U -r openslides-backend/cli/requirements.txt
|
2021-08-04 12:44:39 +02:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: set pythonpath
|
|
|
|
run: echo "PYTHONPATH=openslides-backend" >> $GITHUB_ENV
|
2021-02-05 17:08:29 +01:00
|
|
|
|
2021-08-10 18:44:22 +02:00
|
|
|
- name: generate models.py for next step
|
|
|
|
run: python openslides-backend/cli/generate_models.py docs/models.yml
|
|
|
|
|
|
|
|
- name: Validate example-data.json
|
|
|
|
run: python openslides-backend/cli/check_json.py docs/example-data.json
|
2021-08-11 11:29:12 +02:00
|
|
|
|
2021-08-30 17:11:15 +02:00
|
|
|
validate-initial-data-1:
|
|
|
|
name: Validate initial-data.json without migration check
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Checkout backend submodule
|
|
|
|
run: git submodule update --init openslides-backend/
|
2021-08-18 08:10:31 +02:00
|
|
|
|
2021-08-30 17:11:15 +02:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
|
|
|
|
- name: Install requirements
|
|
|
|
run: pip install -U -r openslides-backend/cli/requirements.txt
|
|
|
|
|
|
|
|
- name: set pythonpath
|
|
|
|
run: echo "PYTHONPATH=openslides-backend" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: generate models.py for next step
|
|
|
|
run: python openslides-backend/cli/generate_models.py docs/models.yml
|
|
|
|
|
|
|
|
- name: Validate example-data.json
|
|
|
|
run: python openslides-backend/cli/check_json.py docker/initial-data.json
|
|
|
|
|
|
|
|
validate-initial-data-2:
|
|
|
|
name: Validate initial-data.json with migration check
|
2021-08-18 08:10:31 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
|
|
|
|
- name: Checkout backend and datastore
|
|
|
|
run: git submodule update --init openslides-backend/ openslides-datastore-service/
|
|
|
|
|
|
|
|
- name: set pythonpath
|
|
|
|
run: echo "PYTHONPATH=openslides-backend" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Install requirements
|
|
|
|
run: pip install -U -r openslides-backend/cli/requirements.txt
|
|
|
|
|
|
|
|
- name: build backend
|
|
|
|
working-directory: openslides-backend/
|
|
|
|
run: make build-prod # creates openslides-backend image
|
|
|
|
|
|
|
|
- name: build datastore
|
|
|
|
working-directory: openslides-datastore-service/
|
|
|
|
run: make build # creates openslides-datatore-reader and openslides-datastore-writer images
|
|
|
|
|
|
|
|
- name: run setup
|
|
|
|
working-directory: .github/initial-data-migrations/
|
|
|
|
run: docker-compose up -d
|
|
|
|
|
|
|
|
- name: Wait for action service # The datastore is started, too
|
|
|
|
working-directory: .github/initial-data-migrations/
|
|
|
|
run: docker-compose exec -T backend ./wait.sh backend 9002
|
2021-08-30 17:11:15 +02:00
|
|
|
|
2021-08-18 08:10:31 +02:00
|
|
|
- name: Inject initial data into the datastore
|
|
|
|
working-directory: .github/initial-data-migrations/
|
|
|
|
run: docker-compose exec -T writer bash -c "source export-database-variables.sh; echo '$(cat ../../docker/initial-data.json)' > /data.json; export DATASTORE_INITIAL_DATA_FILE=/data.json; python cli/create_initial_data.py"
|
|
|
|
|
2021-08-30 17:11:15 +02:00
|
|
|
#- name: Export unmigrated data from the datastore
|
|
|
|
# run: "curl --header 'Content-Type: application/json' -d '{}' http://localhost:9010/internal/datastore/reader/get_everything 2> /dev/null | python3 dev-commands/strip-meta-fields.py > export.json"
|
2021-08-18 08:10:31 +02:00
|
|
|
|
2021-08-30 17:11:15 +02:00
|
|
|
#- name: Validate initial-data.json. It must fail since it is unmigrated
|
|
|
|
# run: if python openslides-backend/cli/check_json.py --partial export.json > /dev/null; then false; else true; fi
|
2021-08-18 08:10:31 +02:00
|
|
|
|
2021-08-30 17:11:15 +02:00
|
|
|
- name: Migrate (but there should be nothing to do)
|
2021-08-18 08:10:31 +02:00
|
|
|
working-directory: .github/initial-data-migrations/
|
|
|
|
run: docker-compose exec -T backend bash -c "source ./entrypoint.sh; cd migrations; python migrate.py finalize"
|
|
|
|
|
|
|
|
- name: Export migrated data from the datastore
|
|
|
|
run: "curl --header 'Content-Type: application/json' -d '{}' http://localhost:9010/internal/datastore/reader/get_everything 2> /dev/null | python3 dev-commands/strip-meta-fields.py > export.json"
|
|
|
|
|
2021-08-30 17:11:15 +02:00
|
|
|
- name: Validate exported initial-data.json
|
2021-08-18 08:10:31 +02:00
|
|
|
run: python openslides-backend/cli/check_json.py --partial export.json
|