diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..85368a8 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,29 @@ +- job: + name: ara-build-dashboard + # https://zuul.openstack.org/job/build-javascript-content + parent: build-javascript-content + description: | + Uses a Ubuntu Xenial VM with Node 8 to run "npm run build" and make the + results available for browsing during code review on review.openstack.org. + It sets the homepage parameter from package.json to the URL where logs will + be uploaded and configures the API server to api.demo.recordsansible.org. + success-url: 'npm/html/' + files: + - public/.* + - src/.* + - .zuul.yaml + - zuul-playbooks/.* + vars: + node_version: 8 + npm_command: build + javascript_content_dir: build + pre-run: zuul-playbooks/pre.yaml + run: zuul-playbooks/build-dashboard.yaml + +- project: + check: + jobs: + - ara-build-dashboard + gate: + jobs: + - ara-build-dashboard diff --git a/zuul-playbooks/README.rst b/zuul-playbooks/README.rst new file mode 100644 index 0000000..3d76265 --- /dev/null +++ b/zuul-playbooks/README.rst @@ -0,0 +1,8 @@ +zuul-playbooks +============== + +These playbooks are used for continuous integration jobs with Zuul_. + +They are not meant to be used on their own. + +.. _Zuul: https://zuul-ci.org diff --git a/zuul-playbooks/build-dashboard.yaml b/zuul-playbooks/build-dashboard.yaml new file mode 100644 index 0000000..6d3b831 --- /dev/null +++ b/zuul-playbooks/build-dashboard.yaml @@ -0,0 +1,7 @@ +- name: Build ARA web dashboard with Zuul + hosts: all + roles: + - revoke-sudo + - set-zuul-log-path-fact + - role: npm + npm_command: build diff --git a/zuul-playbooks/pre.yaml b/zuul-playbooks/pre.yaml new file mode 100644 index 0000000..b9485bb --- /dev/null +++ b/zuul-playbooks/pre.yaml @@ -0,0 +1,39 @@ +- name: Set up package.json and config.json for CI with Zuul + hosts: all + vars: + config: + apiURL: "https://api.demo.recordsansible.org" + project_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + tasks: + # Before building the application, we need to: + # 1) Set the homepage argument from package.json to use the URL where logs will be uploaded. + # 2) Set the API server in public/config.json to use api.demo.recordsansible.org + - name: Resolve Zuul log path + include_role: + name: set-zuul-log-path-fact + + - name: Read package.json + command: "cat {{ project_dir }}/package.json" + register: package_json + + - name: Set homepage parameter + vars: + build_url: "http://logs.openstack.org/{{ zuul_log_path }}/npm/html/" + set_fact: + package_json: "{{ package_json.stdout | from_json | combine({'homepage': build_url}) }}" + + - name: Write package.json + copy: + content: "{{ package_json | to_nice_json }}" + dest: "{{ project_dir }}/package.json" + + - name: Set config.json to use api.demo.recordsansible.org + copy: + content: "{{ config | to_nice_json }}" + dest: "{{ project_dir }}/public/config.json" + + - name: Read files for debug purposes + command: "cat {{ item }}" + loop: + - "{{ project_dir }}/package.json" + - "{{ project_dir }}/public/config.json"