Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable build #19

Merged
merged 25 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e156f3e
Make build steps configurable
peterMuriuki Mar 15, 2021
63cbf22
Remove var for package transpiling
peterMuriuki Mar 15, 2021
de19cd1
Move converge and prepater to allow for several scenarios
peterMuriuki Mar 15, 2021
7fc7cd1
Change name of default scneario
peterMuriuki Mar 15, 2021
be0396a
Add scenario for opensrp web
peterMuriuki Mar 15, 2021
1994046
Refactor default vars to apply for reveal-frontend
peterMuriuki Mar 15, 2021
79cc9b6
Fix a few variable bugs in configuration yml
peterMuriuki Mar 15, 2021
7327bec
Run all tests in github actions
peterMuriuki Mar 15, 2021
9d74ca6
Use https over ssh when cloning repo
peterMuriuki Mar 15, 2021
9d80677
Update cache and silently install pythondocker
peterMuriuki Mar 15, 2021
2770e03
Use please to run install command
peterMuriuki Mar 15, 2021
b00fe16
Remove python-docer lib
peterMuriuki Mar 15, 2021
cf2e6c2
Revert "Remove python-docer lib"
peterMuriuki Mar 15, 2021
8181c89
Separate update and install commands
peterMuriuki Mar 15, 2021
5ee8577
Shaking up docker setup in github actions
peterMuriuki Mar 15, 2021
e5230e0
Update molecule version
peterMuriuki Mar 15, 2021
64e3f74
Ignore cache and venv folders
peterMuriuki Mar 15, 2021
db8d9db
exclude venv yml files from linting
peterMuriuki Mar 15, 2021
a930511
Add asnible and ansible-lint
peterMuriuki Mar 15, 2021
6f50f66
Fix linting errors
peterMuriuki Mar 15, 2021
1791a73
Force to specify the rolename by ansible-lint
peterMuriuki Mar 15, 2021
82b968c
Remove unused flake8
peterMuriuki Mar 15, 2021
711159e
Refactor lint commands in default scenario
peterMuriuki Mar 15, 2021
0369f31
Revert "Shaking up docker setup in github actions"
peterMuriuki Mar 15, 2021
f2b38e5
Remove pythonDocker again
peterMuriuki Mar 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ jobs:
- name: Install dependencies
run: |
docker --version
sudo apt install python-docker
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with molecule
run: |
molecule test
molecule test --all
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
*.log
yarn.lock
.vagrant/
*.pyc
*.pyc
venv/
.cache/
3 changes: 3 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
extends: default

ignore:
venv/

rules:
braces:
max-spaces-inside: 1
Expand Down
14 changes: 13 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
# 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"
Expand Down Expand Up @@ -29,13 +37,17 @@ 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
react_app_path: "{{ react_checkout_path }}"
react_log_path: "/var/log/{{ react_app_name }}"
react_max_versioned_folders: 10
react_build_cmds:
- cmd: build
path: "{{react_app_path}}"
react_build_cmds_default_env: {}
react_build_default_cmd: build

# app settings
react_app_settings:
Expand Down
2 changes: 2 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
galaxy_info:
role_name: react
namespace: "ona"
author: Ona Engineering
company: Ona Systems Inc
description: Install and configure React
Expand Down
12 changes: 7 additions & 5 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ dependency:
driver:
name: docker
platforms:
- name: ubuntu-18.04
- name: ubuntu-1804-default
image: solita/ubuntu-systemd:18.04
privileged: true
command: /sbin/init
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
Expand All @@ -34,4 +36,4 @@ scenario:
lint: |
set -e
yamllint .
flake8
ansible-lint .
17 changes: 17 additions & 0 deletions molecule/resources/playbooks/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- 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/onaio/reveal-frontend.git"
react_git_version: "v1.0.0"
react_app_settings:
GENERATE_SOURCEMAP: "false"
SKIP_PREFLIGHT_CHECK: "true"
react_remote_js_build: true
react_app_path: "{{ react_checkout_path }}"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@
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_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
39 changes: 39 additions & 0 deletions molecule/ubuntu-1804-opensrp/molecule.yml
Original file line number Diff line number Diff line change
@@ -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 .
ansible-lint .
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
molecule[docker]==3.1.4
flake8==3.7.9
molecule[docker]==3.2.3
yamllint==1.25.0
testinfra==4.1.0
testinfra==4.1.0
ansible==3.1.0
ansible-base==2.10.6
ansible-lint==5.0.3
40 changes: 19 additions & 21 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
delegate_to: localhost
become: true
become_user: "{{ react_local_user }}"
delegate_to: localhost
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
args:
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
block:
Expand All @@ -49,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
Expand Down Expand Up @@ -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: 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
args:
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"

Expand Down