Github Actions 4 years ago
parent
commit
5367412760
  1. 11
      .DINAR/config.yaml
  2. 172
      .github/workflows/DINAR-pr.yml
  3. 60
      .github/workflows/DINAR.yml
  4. 2
      .pylintrc
  5. 2
      .pylintrc-mandatory

11
.DINAR/config.yaml

@ -0,0 +1,11 @@
addons:
# modules to install before running tests
include:
- contacts
# modules to exclude from installation/testing
exclude:
- hw_proxy
server_wide_modules:
- web

172
.github/workflows/DINAR-pr.yml

@ -1,3 +1,16 @@
# Copyright 2020 IT Projects Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "DINAR"
on:
@ -6,6 +19,10 @@ on:
jobs:
pre-commit:
name: "pre-commit"
# Let Quick Review/Tests run first
needs:
- review
- tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
@ -42,14 +59,14 @@ jobs:
python-version: "3.7.x"
- name: Install python tools
run: |
pip install plumbum PyGithub
pip install plumbum PyGithub pyyaml
- name: Analyze PR
run: |
# sets environment variables that available in next steps via $ {{ env.PR_... }} notation
cd REPO
python ../DINAR/workflow-files/analyze-pr.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }}
python ../DINAR/workflow-files/analyze-modules.py updated ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }}
- name: HOW TO RUN LOCALLY
#if: "env.PR_UPDATED_MODULES_INSTALLABLE != ''"
#if: "env.PR_MODULES != ''"
run: |
cat << 'EOF'
To test updates run:
@ -68,7 +85,8 @@ jobs:
git -C pr-files fetch origin $REVISION
git -C pr-files checkout FETCH_HEAD
docker-compose pull
export MODULES=${{ env.PR_UPDATED_MODULES_INSTALLABLE }}
export MODULES=${{ env.PR_MODULES }}
export LOAD_MODULES=${{ env.PR_MODULES_LOAD }}
EOF
if [ "${{ github.event.pull_request.base.ref }}" == "10.0" ]; then
@ -92,3 +110,149 @@ jobs:
EOF
# TODO: post this message when Github guys make access to post message in PR
#> Sent by [DINAR :construction_worker_man:](https://github.com/itpp-labs/DINAR) via `.github/workflows/DINAR-pr.yml`
- name: Check Python Version
run:
echo "::set-env name=PY::$(python --version --version | sha256sum | cut -d' '
-f1)"
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('REPO/.pre-commit-config.yaml') }}
- name: Install pre-commit
run: |
pip install pre-commit
- name: PRE-COMMIT against updated files only
run: |
cd REPO
git fetch origin ${{ github.event.pull_request.base.ref }}
pre-commit run --show-diff-on-failure --color=always --origin HEAD --source origin/${{ github.event.pull_request.base.ref }}
tests:
name: "Quick Tests"
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
path: REPO
- name: Checkout DINAR
uses: actions/checkout@v2
with:
path: DINAR
repository: itpp-labs/DINAR
ref: master # TODO: use fixed version
- name: Configure docker
run: |
bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN }}
- name: Install python tools
run: |
pip install plumbum PyGithub pyyaml
- name: Download Docker images with preinstalled modules
run: |
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml pull
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --no-start
- name: Analyze PR
run: |
# Get list of installed modules
ODOO_BASE_MODULES=$(docker inspect \
--format '{{ index .Config.Labels "dinar.odoo.modules"}}' \
dinar_odoo_1)
# sets environment variables that available in next steps via $ {{ env.PR_... }} notation
cd REPO
python ../DINAR/workflow-files/analyze-modules.py updated ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} ${{ github.event.number }} $ODOO_BASE_MODULES
- name: Install json parser
run: |
sudo apt-get install jq
- name: Install Additional Dependencies (Modules)
if: env.PR_MODULES_DEPS != ''
run: |
# Install new dependencies without tests
export MODULES="${{ env.PR_MODULES_DEPS }}"
export LOAD_MODULES="${{ env.PR_MODULES_LOAD }}"
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit
- name: Install Additional Dependencies (Packages)
if: env.PR_DEPS != ''
run: |
# TODO https://github.com/itpp-labs/DINAR/issues/42
exit 1
- name: Prepare DINAR with additional dependencies
if: env.PR_MODULES_DEPS != '' || env.PR_DEPS != ''
run: |
# Save artifacts for local run and for integrations Tests
bash DINAR/workflow-files/save-docker-layers.sh new-deps/
echo $MODULES > new-deps/modules.txt
- name: Save DINAR with dependencies
if: env.PR_MODULES_DEPS != '' || env.PR_DEPS != ''
uses: actions/upload-artifact@v1
with:
name: new-deps
path: new-deps/
- name: Test updated modules
if: env.PR_MODULES != ''
run: |
export MODULES="${{ env.PR_MODULES }}"
export LOAD_MODULES="${{ env.PR_MODULES_LOAD }}"
export ODOO_EXTRA_ARG=--test-enable
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit
tests-all:
name: Integration Tests
# Let Quick Review/Tests run first
# This job uses artifacts from "Quick Tests"
needs:
- tests
- review
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
path: REPO
- name: Checkout DINAR
uses: actions/checkout@v2
with:
path: DINAR
repository: itpp-labs/DINAR
ref: master # TODO: use fixed version
- name: Install python tools
run: |
pip install plumbum pyyaml
- name: Download Additional Dependencies artifact
uses: actions/download-artifact@v1
with:
name: new-deps
path: new-deps/
- name: Check artifact
if: failure()
run: |
echo "::set-env name=ARTIFACT::0"
- name: Configure Docker
run: |
bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN }}
- name: Analyze PR
run: |
# sets environment variables that available in next steps via $ {{ env.PR_... }} notation
DEPS_MODULES=$(cat new-deps/modules.txt || true)
cd REPO
python ../DINAR/workflow-files/analyze-modules.py all "$DEPS_MODULES"
- name: Download base images
run: |
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml pull
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --no-start
- name: Apply new-deps artifact
if: env.ARTIFACT != '0'
run: |
bash DINAR/workflow-files/load-docker-layers.sh new-deps/
- name: Test all modules
run: |
export MODULES="${{ env.ALL_MODULES }}"
export LOAD_MODULES="${{ env.ALL_MODULES_LOAD }}"
export ODOO_EXTRA_ARG=--test-enable
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml config
docker-compose -p DINAR -f DINAR/workflow-files/docker-compose-DINAR-pr.yml up --abort-on-container-exit

60
.github/workflows/DINAR.yml

@ -1,3 +1,16 @@
# Copyright 2020 IT Projects Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "DINAR: Docker Image Building"
on:
@ -22,7 +35,7 @@ jobs:
with:
path: DINAR
repository: itpp-labs/DINAR
ref: master
ref: master # TODO: use fixed version
- uses: actions/setup-python@v1
with:
python-version: "3.7.x"
@ -30,23 +43,11 @@ jobs:
run: |
cp -rnT DINAR/embedded-files/ REPO/
- name: Set vars
- name: Configure Docker
run: |
REF="${{ github.ref }}"
BRANCH=${REF##*/}
REPOSITORY="${{ github.repository }}"
REPO_NAME=${REPOSITORY##*/}
IMAGE_CODE=$REPO_NAME:$BRANCH
ODOO_VERSION="$(echo $BRANCH | python DINAR/workflow-files/branch2odoo_version.py)"
echo "ODOO_VERSION=$ODOO_VERSION"
echo "::set-env name=ODOO_VERSION::$ODOO_VERSION"
echo "::set-env name=IMAGE_ODOO_BASE::${{ github.repository }}/dinar-deps-$IMAGE_CODE"
echo "::set-env name=IMAGE_CODE::$IMAGE_CODE"
# Registry credentials. External registry potentially can be customized here
echo "::set-env name=REGISTRY::docker.pkg.github.com"
echo "::set-env name=REGISTRY_USERNAME::${{ github.actor }}"
echo "::set-env name=REGISTRY_PASSWORD::${{ secrets.DINAR_TOKEN }}"
- name: Handle Dependencies
bash DINAR/workflow-files/configure-docker.sh ${{ secrets.DINAR_TOKEN }}
- name: dinar-odoo-base
uses: elgohr/Publish-Docker-Github-Action@master
env:
LOCAL_CUSTOM_DIR: ./image
@ -62,25 +63,20 @@ jobs:
buildargs: ODOO_VERSION,AGGREGATE,PIP_INSTALL_ODOO,CLEAN,COMPILE,LOCAL_CUSTOM_DIR
workdir: REPO/.DINAR/
cache: ${{ github.event_name != 'schedule' }}
- name: Install shyaml
- name: Install python tools
run: |
pip install plumbum pyyaml
- name: Compute Modules Dependencies
run: |
pip install shyaml
# sets environment variables that available in next steps via $ {{ env.VAR_NAME }} notation
cd REPO
python ../DINAR/workflow-files/analyze-modules.py all
- name: Install Base Addons
run: |
# authenticate
echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY"
# convert "base-addons" list to comma-separated list
export MODULES=$(cat REPO/.DINAR/volumes/addons.yaml | shyaml get-values base-addons | xargs | sed "s/ /,/g")
export DB_VERSION=10
export REPOSITORY=${{ github.repository }}
export MODULES=$ALL_MODULES_DEPENDENCIES
export DOODBA_WITHOUT_DEMO=all
export IMAGE_DB=${{ github.repository }}/dinar-db-nodemo-$IMAGE_CODE
export IMAGE_ODOO=${{ github.repository }}/dinar-odoo-nodemo-$IMAGE_CODE
bash DINAR/workflow-files/images-with-preinstalled-modules.sh
bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB-nodemo $IMAGE_ODOO-nodemo
export DOODBA_WITHOUT_DEMO=false
export IMAGE_DB=${{ github.repository }}/dinar-db-$IMAGE_CODE
export IMAGE_ODOO=${{ github.repository }}/dinar-odoo-$IMAGE_CODE
bash DINAR/workflow-files/images-with-preinstalled-modules.sh
bash DINAR/workflow-files/images-with-preinstalled-modules.sh $IMAGE_DB $IMAGE_ODOO

2
.pylintrc

@ -4,7 +4,7 @@ score=n
[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors=IT-Projects Labs
manifest_required_authors=IT Projects Labs
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3,MIT,Other OSI approved licence,OPL-1

2
.pylintrc-mandatory

@ -4,7 +4,7 @@ score=n
[ODOOLINT]
readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst"
manifest_required_authors=IT-Projects Labs
manifest_required_authors=IT Projects Labs
manifest_required_keys=license
manifest_deprecated_keys=description,active
license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3,MIT,Other OSI approved licence,OPL-1

Loading…
Cancel
Save