From b05be3b64562baf099e8485171ea2160ddcc21e0 Mon Sep 17 00:00:00 2001 From: Kipchirchir Sigei Date: Fri, 13 Nov 2020 12:11:58 +0300 Subject: [PATCH 01/29] Add task to compile all packages Signed-off-by: Kipchirchir Sigei --- tasks/configure.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasks/configure.yml b/tasks/configure.yml index 4ab8980..934c98b 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -18,6 +18,15 @@ become: true become_user: "{{ react_local_user }}" + - name: Transpile packages + command: yarn run lerna:prepublish + args: + chdir: "{{ react_local_checkout_path }}" + delegate_to: localhost + become: true + become_user: "{{ react_local_user }}" + ignore_errors: true + - name: Compile Javascript locally command: yarn build args: From 3ccf8241635ef7122c0de03755512e0c43cb87dd Mon Sep 17 00:00:00 2001 From: Kipchirchir Sigei Date: Fri, 13 Nov 2020 12:31:42 +0300 Subject: [PATCH 02/29] Add flag to optionally transpile packages Signed-off-by: Kipchirchir Sigei --- tasks/configure.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/configure.yml b/tasks/configure.yml index 934c98b..825de8e 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -26,6 +26,7 @@ become: true become_user: "{{ react_local_user }}" ignore_errors: true + when: "react_transpile_packages" - name: Compile Javascript locally command: yarn build From aea0808786d6aa7609361817a57675f6ae6f6ea6 Mon Sep 17 00:00:00 2001 From: Kipchirchir Sigei Date: Wed, 18 Nov 2020 11:58:39 +0300 Subject: [PATCH 03/29] Add react_transpile_packages to defaults Signed-off-by: Kipchirchir Sigei --- defaults/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/defaults/main.yml b/defaults/main.yml index 9925a99..91f1456 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,6 +29,7 @@ react_env_name: "prod" react_app_name: "{{ react_system_user }}" react_codebase_path: "{{ react_system_user_home }}/app" react_versioned_path: "{{ react_codebase_path }}-versioned" +react_transpile_packages: true # where the repository is cloned react_checkout_path: "{{ react_versioned_path }}/{{ ansible_date_time['epoch'] }}" # where the actual app package is From e156f3e6bccf2d5dffee9089eaea841b57825074 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 13:46:18 +0300 Subject: [PATCH 04/29] Make build steps configurable --- defaults/main.yml | 13 +++++++++++++ tasks/configure.yml | 38 ++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 91f1456..0405677 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,4 +1,12 @@ --- +# react_build_cmds: +# - run: build # yarn command to run +# args: --production # optional arguements to pass +# path: /var/www/myapp # optional chdir path +# ignore_errors: yes # optional don't fail on react errors +# env: # optional environment settings +# NODE_ENV: production + # user react_system_user: "react" react_system_group: "www-data" @@ -36,6 +44,11 @@ react_checkout_path: "{{ react_versioned_path }}/{{ ansible_date_time['epoch'] } react_app_path: "{{ react_checkout_path }}" react_log_path: "/var/log/{{ react_app_name }}" react_max_versioned_folders: 10 +react_build_cmds: + - run: build + path: "{{react_app_path}}" +react_build_cmds_default_env: {} +react_build_default_cmd: build # app settings react_app_settings: diff --git a/tasks/configure.yml b/tasks/configure.yml index 825de8e..619c880 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -18,23 +18,17 @@ become: true become_user: "{{ react_local_user }}" - - name: Transpile packages - command: yarn run lerna:prepublish - args: - chdir: "{{ react_local_checkout_path }}" - delegate_to: localhost - become: true + - name: Build app locally become_user: "{{ react_local_user }}" - ignore_errors: true - when: "react_transpile_packages" - - - name: Compile Javascript locally - command: yarn build - args: - chdir: "{{ react_local_checkout_path }}" + become: yes delegate_to: localhost - become: true - become_user: "{{ react_local_user }}" + environment: "{{ item.env | default(react_build_cmds_default_env) }}" + command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.run }} {{ item.args | default() }}" + register: yarn_build_result + args: + chdir: "{{ item.path | default(omit) }}" + failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find(yarn) != -1" + with_items: "{{ react_build_cmds }}" - name: Remove node_modules before compression block: @@ -86,12 +80,16 @@ become: true become_user: "{{ react_system_user }}" - - name: Compile Javascript - command: yarn build - args: - chdir: "{{ react_checkout_path }}" - become: true + - name: Build app locally become_user: "{{ react_system_user }}" + become: yes + environment: "{{ item.env | default(react_build_cmds_default_env) }}" + command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.run }} {{ item.args | default() }}" + register: yarn_build_result + args: + chdir: "{{ item.path | default(omit) }}" + failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find(yarn) != -1" + with_items: "{{ react_build_cmds }}" when: "react_remote_js_build|bool" From 63cbf22a996a82551d3091e4c601630dd3dd3d95 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 13:47:10 +0300 Subject: [PATCH 05/29] Remove var for package transpiling --- defaults/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 0405677..6f9c2a2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -37,7 +37,6 @@ react_env_name: "prod" react_app_name: "{{ react_system_user }}" react_codebase_path: "{{ react_system_user_home }}/app" react_versioned_path: "{{ react_codebase_path }}-versioned" -react_transpile_packages: true # where the repository is cloned react_checkout_path: "{{ react_versioned_path }}/{{ ansible_date_time['epoch'] }}" # where the actual app package is From de19cd19fe63a07a3e3e2de5cd43c05d6a5af1b0 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 14:15:55 +0300 Subject: [PATCH 06/29] Move converge and prepater to allow for several scenarios --- molecule/default/molecule.yml | 8 +++++--- molecule/{default => resources/playbooks}/converge.yml | 0 molecule/{default => resources/playbooks}/prepare.yml | 0 .../playbooks}/tests/test_default.py | 0 4 files changed, 5 insertions(+), 3 deletions(-) rename molecule/{default => resources/playbooks}/converge.yml (100%) rename molecule/{default => resources/playbooks}/prepare.yml (100%) rename molecule/{default => resources/playbooks}/tests/test_default.py (100%) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 261f036..3e86dd2 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -11,12 +11,14 @@ platforms: provisioner: log: true name: ansible - playbook: - prepare: prepare.yml + playbooks: + prepare: ../resources/playbooks/prepare.yml + converge: ../resources/playbooks/converge.yml options: - verbose: true + vvv: True verifier: name: testinfra + directory: ../resources/tests/ scenario: test_sequence: - dependency diff --git a/molecule/default/converge.yml b/molecule/resources/playbooks/converge.yml similarity index 100% rename from molecule/default/converge.yml rename to molecule/resources/playbooks/converge.yml diff --git a/molecule/default/prepare.yml b/molecule/resources/playbooks/prepare.yml similarity index 100% rename from molecule/default/prepare.yml rename to molecule/resources/playbooks/prepare.yml diff --git a/molecule/default/tests/test_default.py b/molecule/resources/playbooks/tests/test_default.py similarity index 100% rename from molecule/default/tests/test_default.py rename to molecule/resources/playbooks/tests/test_default.py From 7fc7cd19a551e08c8c3b6e39e9e6d0fb059aa576 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 14:18:16 +0300 Subject: [PATCH 07/29] Change name of default scneario --- molecule/default/molecule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 3e86dd2..8f5085c 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -4,7 +4,7 @@ dependency: driver: name: docker platforms: - - name: ubuntu-18.04 + - name: ubuntu-1804-default image: solita/ubuntu-systemd:18.04 privileged: true command: /sbin/init From be0396a017e38c635da1d507a3156b77c333e183 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:22:28 +0300 Subject: [PATCH 08/29] Add scenario for opensrp web --- molecule/ubuntu-1804-opensrp/converge.yml | 23 +++++++++++++ molecule/ubuntu-1804-opensrp/molecule.yml | 39 +++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 molecule/ubuntu-1804-opensrp/converge.yml create mode 100644 molecule/ubuntu-1804-opensrp/molecule.yml diff --git a/molecule/ubuntu-1804-opensrp/converge.yml b/molecule/ubuntu-1804-opensrp/converge.yml new file mode 100644 index 0000000..57f0b6d --- /dev/null +++ b/molecule/ubuntu-1804-opensrp/converge.yml @@ -0,0 +1,23 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible-react + vars: + react_system_user: "react" + react_system_group: "www-data" + react_system_user_home: "/home/{{ react_system_user }}" + react_node_version: 10.x + react_git_url: "https://github.com/OpenSRP/web.git" + react_git_version: "master" + react_app_settings: + GENERATE_SOURCEMAP: "false" + SKIP_PREFLIGHT_CHECK: "true" + react_remote_js_build: false + react_local_app_path: "{{ react_local_checkout_path }}/app" + react_app_path: "{{ react_checkout_path }}/app" + react_build_cmds: + - cmd: lerna:prepublish + args: --scope @opensrp/store + - cmd: lerna:prepublish + - cmd: build diff --git a/molecule/ubuntu-1804-opensrp/molecule.yml b/molecule/ubuntu-1804-opensrp/molecule.yml new file mode 100644 index 0000000..047102f --- /dev/null +++ b/molecule/ubuntu-1804-opensrp/molecule.yml @@ -0,0 +1,39 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: ubuntu-1804-opensrp + image: solita/ubuntu-systemd:18.04 + privileged: true + command: /sbin/init +provisioner: + log: true + name: ansible + playbooks: + prepare: ../resources/playbooks/prepare.yml + converge: converge.yml + options: + vvv: False +verifier: + name: testinfra + directory: ../resources/tests/ +scenario: + test_sequence: + - dependency + - lint + - cleanup + - destroy + - syntax + - create + - prepare + - converge + - side_effect + - verify + - cleanup + - destroy +lint: | + set -e + yamllint . + flake8 From 19940464b997569d14dcc7056de4f0f2a435f13d Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:22:49 +0300 Subject: [PATCH 09/29] Refactor default vars to apply for reveal-frontend --- molecule/resources/playbooks/converge.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/molecule/resources/playbooks/converge.yml b/molecule/resources/playbooks/converge.yml index 9ce1180..1d5c3dc 100644 --- a/molecule/resources/playbooks/converge.yml +++ b/molecule/resources/playbooks/converge.yml @@ -8,11 +8,10 @@ react_system_group: "www-data" react_system_user_home: "/home/{{ react_system_user }}" react_node_version: 10.x - react_git_url: "https://github.com/OpenSRP/web.git" - react_git_version: "master" + react_git_url: "git@github.com:onaio/reveal-frontend.git" + react_git_version: "v1.0.0" react_app_settings: GENERATE_SOURCEMAP: "false" SKIP_PREFLIGHT_CHECK: "true" - react_remote_js_build: false - react_local_app_path: "{{ react_local_checkout_path }}/client" - react_app_path: "{{ react_checkout_path }}/client" + react_remote_js_build: true + react_app_path: "{{ react_checkout_path }}" From 79cc9b6f15a799c95ca9ca8878e09456d24db3bf Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:23:23 +0300 Subject: [PATCH 10/29] Fix a few variable bugs in configuration yml --- defaults/main.yml | 4 ++-- tasks/configure.yml | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6f9c2a2..55eba81 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- # react_build_cmds: -# - run: build # yarn command to run +# - cmd: build # yarn command to run # args: --production # optional arguements to pass # path: /var/www/myapp # optional chdir path # ignore_errors: yes # optional don't fail on react errors @@ -44,7 +44,7 @@ react_app_path: "{{ react_checkout_path }}" react_log_path: "/var/log/{{ react_app_name }}" react_max_versioned_folders: 10 react_build_cmds: - - run: build + - cmd: build path: "{{react_app_path}}" react_build_cmds_default_env: {} react_build_default_cmd: build diff --git a/tasks/configure.yml b/tasks/configure.yml index 619c880..7154fac 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -23,11 +23,11 @@ become: yes delegate_to: localhost environment: "{{ item.env | default(react_build_cmds_default_env) }}" - command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.run }} {{ item.args | default() }}" + command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.args | default() }}" register: yarn_build_result args: - chdir: "{{ item.path | default(omit) }}" - failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find(yarn) != -1" + chdir: "{{ item.path | default(react_local_checkout_path) }}" + failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find('error ') != -1" with_items: "{{ react_build_cmds }}" - name: Remove node_modules before compression @@ -43,7 +43,7 @@ - name: remove node_modules manually file: - path: "{{ react_checkout_path }}/node_modules" + path: "{{ react_local_checkout_path }}/node_modules" state: absent delegate_to: localhost become: true @@ -84,11 +84,11 @@ become_user: "{{ react_system_user }}" become: yes environment: "{{ item.env | default(react_build_cmds_default_env) }}" - command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.run }} {{ item.args | default() }}" + command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.args | default() }}" register: yarn_build_result args: - chdir: "{{ item.path | default(omit) }}" - failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find(yarn) != -1" + chdir: "{{ item.path | default(react_checkout_path) }}" + failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find('error ') != -1" with_items: "{{ react_build_cmds }}" when: "react_remote_js_build|bool" From 7327bece4bffe9268cf6eb7e5605041be7c75f0f Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:24:30 +0300 Subject: [PATCH 11/29] Run all tests in github actions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a781e9..437e1a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,4 +29,4 @@ jobs: pip install -r requirements.txt - name: Test with molecule run: | - molecule test + molecule test --all From 9d74ca652fe72eaf1fc3c48f18af36f20fdcb5a6 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:30:17 +0300 Subject: [PATCH 12/29] Use https over ssh when cloning repo --- molecule/resources/playbooks/converge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/resources/playbooks/converge.yml b/molecule/resources/playbooks/converge.yml index 1d5c3dc..6c455a6 100644 --- a/molecule/resources/playbooks/converge.yml +++ b/molecule/resources/playbooks/converge.yml @@ -8,7 +8,7 @@ react_system_group: "www-data" react_system_user_home: "/home/{{ react_system_user }}" react_node_version: 10.x - react_git_url: "git@github.com:onaio/reveal-frontend.git" + react_git_url: "https://github.com/onaio/reveal-frontend.git" react_git_version: "v1.0.0" react_app_settings: GENERATE_SOURCEMAP: "false" From 9d806770b17e5fb6f4ab521b1cd856c6c82a0c44 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:54:17 +0300 Subject: [PATCH 13/29] Update cache and silently install pythondocker --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 437e1a6..9a6ad67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | docker --version - sudo apt install python-docker + sudo apt-get update && apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From 2770e03cfe1fe35fba0faeaedd8265d45a3c97a8 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 15:57:15 +0300 Subject: [PATCH 14/29] Use please to run install command --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9a6ad67..06f67a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | docker --version - sudo apt-get update && apt-get -qq -y install python-docker + sudo apt-get update && sudo apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From b00fe167dc5e657b5cddddedce0696eb2b215e1b Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 16:03:22 +0300 Subject: [PATCH 15/29] Remove python-docer lib --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 06f67a7..6f2baf5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,6 @@ jobs: - name: Install dependencies run: | docker --version - sudo apt-get update && sudo apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From cf2e6c2519ec05af2a8a216e757fca63489388e8 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 16:10:47 +0300 Subject: [PATCH 16/29] Revert "Remove python-docer lib" This reverts commit b00fe167dc5e657b5cddddedce0696eb2b215e1b. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f2baf5..06f67a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,6 +24,7 @@ jobs: - name: Install dependencies run: | docker --version + sudo apt-get update && sudo apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From 8181c89b8d4a94df56d2d5343ec197061249e62d Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 16:17:25 +0300 Subject: [PATCH 17/29] Separate update and install commands --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 06f67a7..8cc0c4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,8 @@ jobs: - name: Install dependencies run: | docker --version - sudo apt-get update && sudo apt-get -qq -y install python-docker + sudo apt-get update + sudo apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From 5ee857774532ed178e8cfd2aa4a3cf1a8913c061 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 16:35:09 +0300 Subject: [PATCH 18/29] Shaking up docker setup in github actions --- .github/workflows/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8cc0c4f..52cd37a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,6 @@ jobs: python-version: [3.6] steps: - - uses: docker-practice/actions-setup-docker@master - uses: actions/checkout@v1 with: path: "${{ github.repository }}" @@ -23,9 +22,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - docker --version - sudo apt-get update - sudo apt-get -qq -y install python-docker + sudo apt install docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From e5230e0818ce731df6afe212d57ea32d393cc6c9 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 17:00:15 +0300 Subject: [PATCH 19/29] Update molecule version --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0f26f6d..6123139 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -molecule[docker]==3.1.4 +molecule[docker]==3.2.3 flake8==3.7.9 yamllint==1.25.0 -testinfra==4.1.0 \ No newline at end of file +testinfra==4.1.0 From 64e3f7412c937cf3529543e840cf37485c1622c0 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 17:58:40 +0300 Subject: [PATCH 20/29] Ignore cache and venv folders --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2d20fc7..172f3af 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ *.log yarn.lock .vagrant/ -*.pyc \ No newline at end of file +*.pyc +venv/ +.cache/ From db8d9db7527e13e4020f65acb246dada284b5717 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 17:59:13 +0300 Subject: [PATCH 21/29] exclude venv yml files from linting --- .yamllint | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.yamllint b/.yamllint index d755e05..8ff547d 100644 --- a/.yamllint +++ b/.yamllint @@ -1,6 +1,9 @@ --- extends: default +ignore: + venv/ + rules: braces: max-spaces-inside: 1 From a9305110d7e6047f4d694634df1575208d020fba Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 17:59:37 +0300 Subject: [PATCH 22/29] Add asnible and ansible-lint --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 6123139..80cf637 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,6 @@ molecule[docker]==3.2.3 flake8==3.7.9 yamllint==1.25.0 testinfra==4.1.0 +ansible==3.1.0 +ansible-base==2.10.6 +ansible-lint==5.0.3 From 6f50f669995857e68cb7d26dcb559b7674ad83ce Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 17:59:56 +0300 Subject: [PATCH 23/29] Fix linting errors --- molecule/default/molecule.yml | 2 +- molecule/ubuntu-1804-opensrp/molecule.yml | 4 ++-- tasks/configure.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 8f5085c..0a65f80 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -15,7 +15,7 @@ provisioner: prepare: ../resources/playbooks/prepare.yml converge: ../resources/playbooks/converge.yml options: - vvv: True + vvv: true verifier: name: testinfra directory: ../resources/tests/ diff --git a/molecule/ubuntu-1804-opensrp/molecule.yml b/molecule/ubuntu-1804-opensrp/molecule.yml index 047102f..6eba27c 100644 --- a/molecule/ubuntu-1804-opensrp/molecule.yml +++ b/molecule/ubuntu-1804-opensrp/molecule.yml @@ -15,7 +15,7 @@ provisioner: prepare: ../resources/playbooks/prepare.yml converge: converge.yml options: - vvv: False + vvv: false verifier: name: testinfra directory: ../resources/tests/ @@ -36,4 +36,4 @@ scenario: lint: | set -e yamllint . - flake8 + ansible-lint . diff --git a/tasks/configure.yml b/tasks/configure.yml index 7154fac..1c9c26e 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -20,7 +20,7 @@ - name: Build app locally become_user: "{{ react_local_user }}" - become: yes + become: true delegate_to: localhost environment: "{{ item.env | default(react_build_cmds_default_env) }}" command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.args | default() }}" @@ -82,7 +82,7 @@ - name: Build app locally become_user: "{{ react_system_user }}" - become: yes + become: true environment: "{{ item.env | default(react_build_cmds_default_env) }}" command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.args | default() }}" register: yarn_build_result From 1791a7327d08623be7bb867640afb26ae8ad3169 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 18:00:32 +0300 Subject: [PATCH 24/29] Force to specify the rolename by ansible-lint --- meta/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meta/main.yml b/meta/main.yml index b72dafc..77aebd6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,5 +1,7 @@ --- galaxy_info: + role_name: react + namespace: "ona" author: Ona Engineering company: Ona Systems Inc description: Install and configure React From 82b968c4e836fa24437b89c102bc276af881e13a Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 18:01:06 +0300 Subject: [PATCH 25/29] Remove unused flake8 --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 80cf637..fd4579e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ molecule[docker]==3.2.3 -flake8==3.7.9 yamllint==1.25.0 testinfra==4.1.0 ansible==3.1.0 From 711159e5238f090b0d02ab4c5ef52dc3ea729d6f Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 18:01:34 +0300 Subject: [PATCH 26/29] Refactor lint commands in default scenario --- molecule/default/molecule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 0a65f80..8797a64 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -36,4 +36,4 @@ scenario: lint: | set -e yamllint . - flake8 + ansible-lint . From 0369f31f3a8a0f0da28cc5eaa438a97cd2690434 Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 20:54:08 +0300 Subject: [PATCH 27/29] Revert "Shaking up docker setup in github actions" This reverts commit 5ee857774532ed178e8cfd2aa4a3cf1a8913c061. --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 52cd37a..8cc0c4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,6 +13,7 @@ jobs: python-version: [3.6] steps: + - uses: docker-practice/actions-setup-docker@master - uses: actions/checkout@v1 with: path: "${{ github.repository }}" @@ -22,7 +23,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - sudo apt install docker + docker --version + sudo apt-get update + sudo apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From f2b38e566a8dcd147e0210fe183c9f999952ce0c Mon Sep 17 00:00:00 2001 From: p-netm Date: Mon, 15 Mar 2021 20:56:13 +0300 Subject: [PATCH 28/29] Remove pythonDocker again --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8cc0c4f..6f2baf5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,8 +24,6 @@ jobs: - name: Install dependencies run: | docker --version - sudo apt-get update - sudo apt-get -qq -y install python-docker python -m pip install --upgrade pip pip install -r requirements.txt - name: Test with molecule From 4e2c0c471050fe1abcbbe4241d4a13f0c333288c Mon Sep 17 00:00:00 2001 From: p-netm Date: Tue, 16 Mar 2021 12:18:04 +0300 Subject: [PATCH 29/29] Move comments closer to where its applicable in defaults --- defaults/main.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 55eba81..e809af0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,12 +1,4 @@ --- -# react_build_cmds: -# - cmd: build # yarn command to run -# args: --production # optional arguements to pass -# path: /var/www/myapp # optional chdir path -# ignore_errors: yes # optional don't fail on react errors -# env: # optional environment settings -# NODE_ENV: production - # user react_system_user: "react" react_system_group: "www-data" @@ -43,6 +35,15 @@ react_checkout_path: "{{ react_versioned_path }}/{{ ansible_date_time['epoch'] } react_app_path: "{{ react_checkout_path }}" react_log_path: "/var/log/{{ react_app_name }}" react_max_versioned_folders: 10 + +# shows the full structure of the react_build_cmds variable +# react_build_cmds: +# - cmd: build # yarn command to run +# args: --production # optional arguments to pass +# path: /var/www/myapp # optional chdir path +# ignore_errors: yes # optional don't fail on yarn errors +# env: # optional environment settings +# NODE_ENV: production react_build_cmds: - cmd: build path: "{{react_app_path}}"