Update zuul gates to use docker-image

* use the docker image to lint and test
* install docker on image instead of checking for go,
  the docker image itself is created from a golang base image

Change-Id: I4b1342862973031734a1f1af887fd85ceae325da
This commit is contained in:
Yasin, Siraj (SY495P) 2020-06-30 11:31:52 -05:00
parent fc38c593f2
commit 9ddfd8f69a
9 changed files with 159 additions and 9 deletions

View File

@ -32,12 +32,12 @@
- job:
name: airshipui-test
pre-run: playbooks/install-go.yaml
pre-run: playbooks/install-docker.yaml
run: playbooks/airshipui-test/run.yaml
- job:
name: airshipui-lint
pre-run: playbooks/install-go.yaml
pre-run: playbooks/install-docker.yaml
run: playbooks/airshipui-lint/run.yaml
- job:

View File

@ -14,9 +14,9 @@
- hosts: all
name: Run linter
tasks:
- name: make lint
- name: make docker-image-lint
make:
target: lint
target: docker-image-lint
chdir: "{{ zuul.project.src_dir }}"
environment:
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin"

View File

@ -14,9 +14,9 @@
- hosts: all
name: Run tests
tasks:
- name: make test
- name: make docker-image-unit-tests
make:
target: test
target: docker-image-unit-tests
chdir: "{{ zuul.project.src_dir }}"
environment:
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin"

View File

@ -12,6 +12,6 @@
---
- hosts: all
name: Install Go
name: Install Docker
roles:
- ensure-go
- docker-install

View File

@ -0,0 +1,28 @@
# 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.
docker_config_path: "/etc/docker"
docker_config_log_driver: "journald"
docker_config_log_opts: {}
docker_config: |
{
"log-driver": "{{ docker_config_log_driver }}",
"log-opts": {{ docker_config_log_opts | to_json }}
}
proxy:
enabled: false
http:
https:
noproxy:

View File

@ -0,0 +1,91 @@
# 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: Ensuring docker and support packages are present
become: yes
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
yum:
name:
- docker.io
- runc
update_cache: yes
state: present
- name: Ensuring docker and support packages are present
become: yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
apt:
name:
- docker.io
- runc
update_cache: yes
state: present
- name: Ensure docker group exists
group:
name: docker
state: present
- name: Add user "{{ ansible_user }}" to docker group
become: yes
user:
name: "{{ ansible_user }}"
groups:
- docker
append: yes
- name: Reset ssh connection to add docker group to user
meta: reset_connection
ignore_errors: true
- block:
- name: Create docker directory
file:
path: /etc/systemd/system/docker.service.d/
state: directory
mode: '0755'
- name: Configure proxy for docker if enabled
template:
src: http-proxy-conf.j2
dest: /etc/systemd/system/docker.service.d/http-proxy.conf
when: proxy.enabled|bool == true
become: yes
- name: Create docker directory
file:
path: "{{ docker_config_path }}"
state: directory
mode: '0755'
become: yes
- name: Save docker daemon configuration
copy:
content: "{{ docker_config | to_nice_json }}"
dest: "{{ docker_config_path }}/daemon.json"
become: yes
- name: Start docker
become: yes
systemd:
name: docker
state: restarted
daemon_reload: yes
enabled: true
- name: Change group ownership on docker sock
become: yes
file:
path: /var/run/docker.sock
group: docker

View File

@ -0,0 +1,4 @@
[Service]
Environment="HTTP_PROXY={{ proxy.http }}"
Environment="HTTPS_PROXY={{ proxy.https }}"
Environment="NO_PROXY={{ proxy.noproxy }}"

View File

@ -0,0 +1,25 @@
# 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: install docker
include_role:
name: docker-install
- name: check if docker is installed
shell: "docker version"
register: docker_version
- name: verify docker is installed
assert:
that:
- docker_version.rc == 0

View File

@ -3,6 +3,7 @@ set -x
tools_bin_dir="${BASH_SOURCE%/*}"
node_version=v12.16.3
npm_user=${USER:-root}
if [[ ! -d $tools_bin_dir/node-$node_version ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
@ -40,9 +41,10 @@ if [[ ! -d $tools_bin_dir/node-$node_version ]]; then
# npm will write to a node_modules even with the --directory flag it's better to be in the root of where you want this to live
cd web
npm config set user ${npm_user}
if ! npm install eslint-plugin-html@latest --save-dev; then
printf "Something went wrong while installing eslint-plugin-html\n" 1>&2
exit 1
fi
cd ..
fi
fi