Skip to content

Commit fb658ce

Browse files
committed
Add CI scripts
1 parent 82cdb89 commit fb658ce

15 files changed

+354
-0
lines changed

ci/Vagrantfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Vagrant.require_version ">= 1.7.0"
2+
3+
def configure_vm(name, config)
4+
config.vm.provider "virtualbox" do |v|
5+
v.memory = (ENV['VM_MEM'] || 4096).to_i
6+
v.cpus = (ENV['VM_CPU'] || 2).to_i
7+
v.name = "llvm2graphml-#{name}"
8+
end
9+
end
10+
11+
Vagrant.configure(2) do |config|
12+
13+
config.vm.define "ubuntu18" do |cfg|
14+
cfg.vm.box = "ubuntu/bionic64"
15+
cfg.ssh.insert_key = false
16+
cfg.ssh.forward_agent = true
17+
18+
configure_vm("ubuntu18", cfg)
19+
20+
cfg.vm.provision "shell", inline: "apt-get install -y python"
21+
config.vm.provision "shell", inline: <<-SHELL
22+
mkdir -p ~/.ssh
23+
chmod 700 ~/.ssh
24+
ssh-keyscan -t rsa -H github.com >> ~/.ssh/known_hosts
25+
SHELL
26+
27+
cfg.vm.provision "ansible" do |ansible|
28+
ansible.verbose = "v"
29+
ansible.playbook = "ubuntu-playbook.yaml"
30+
ansible.extra_vars = {
31+
llvm_version: ENV['LLVM_VERSION'] || '9.0.0',
32+
gitref: ENV['GITREF'] || 'master',
33+
}
34+
end
35+
end
36+
37+
config.vm.define "macos" do |cfg|
38+
cfg.vm.box = "yzgyyang/macOS-10.14"
39+
cfg.ssh.insert_key = false
40+
cfg.ssh.forward_agent = true
41+
42+
configure_vm("macOS", cfg)
43+
44+
cfg.vm.synced_folder ".", "/vagrant", disabled: true
45+
cfg.vm.provision "ansible" do |ansible|
46+
ansible.verbose = "v"
47+
ansible.playbook = "macos-playbook.yaml"
48+
ansible.extra_vars = {
49+
llvm_version: ENV['LLVM_VERSION'] || '9.0.0',
50+
gitref: ENV['GITREF'] || 'master',
51+
}
52+
end
53+
end
54+
55+
end

ci/ansible.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[defaults]
2+
stdout_callback = yaml
3+
bin_ansible_callbacks = True

ci/helpers/build-and-test.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
- name: Clone sources
3+
git:
4+
repo: "{{ repo_url }}"
5+
dest: "{{ source_dir }}"
6+
version: "{{ gitref }}"
7+
accept_hostkey: true
8+
ssh_opts: "-o ForwardAgent=yes -o StrictHostKeyChecking=no"
9+
10+
- name: Build
11+
include: helpers/build-llvm2graphml.yaml
12+
vars:
13+
build_dir: "{{ debug_build_dir }}"
14+
build_type: Debug
15+
16+
- name: Run tests
17+
include: helpers/run-tests.yaml
18+
vars:
19+
build_dir: "{{ debug_build_dir }}"
20+
build_type: Debug
21+
22+
- name: Build
23+
include: helpers/build-llvm2graphml.yaml
24+
vars:
25+
build_dir: "{{ release_build_dir }}"
26+
build_type: Release
27+
28+
- name: Run tests
29+
include: helpers/run-tests.yaml
30+
vars:
31+
build_dir: "{{ release_build_dir }}"
32+
build_type: Release

ci/helpers/build-llvm2graphml.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
- name: Create Build Directory ({{ build_type }})
3+
file:
4+
path: "{{ build_dir }}"
5+
state: directory
6+
7+
- name: Prepare Build System ({{ build_type }})
8+
command:
9+
args:
10+
argv:
11+
- cmake
12+
- -DPATH_TO_LLVM={{ llvm_dir }}
13+
- -DCMAKE_BUILD_TYPE={{ build_type }}
14+
- -DCMAKE_CXX_FLAGS="{{ llvm2graphml_cxx_flags }}"
15+
- -DGREMLIN_CONSOLE_EXEC="{{ gremlin_dir }}/bin/gremlin.sh"
16+
- "{{ source_dir }}"
17+
chdir: "{{ build_dir }}"
18+
creates: "{{ build_dir }}/CMakeCache.txt"
19+
environment:
20+
CC: "{{ llvm_dir }}/bin/clang"
21+
CXX: "{{ llvm_dir }}/bin/clang++"
22+
23+
- name: Build llvm2graphml ({{ build_type }})
24+
make:
25+
target: all
26+
chdir: "{{ build_dir }}"

ci/helpers/install-gremlin.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: Download Gremlin
3+
get_url:
4+
url: "{{ gremlin_url }}"
5+
dest: "{{ working_dir }}/gremlin.zip"
6+
timeout: 30
7+
register: download_gremlin
8+
9+
- name: Extract Gremlin
10+
unarchive:
11+
src: "{{ working_dir }}/gremlin.zip"
12+
dest: "{{ working_dir }}"
13+
remote_src: yes
14+
when: download_gremlin.changed

ci/helpers/install-llvm.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: Download LLVM ({{ llvm_version }})
3+
get_url:
4+
url: "{{ llvm_url }}"
5+
dest: "{{ working_dir }}/{{ llvm_version }}.tar.gz"
6+
timeout: 30
7+
register: download_llvm
8+
9+
- name: Extract LLVM ({{ llvm_version }})
10+
unarchive:
11+
src: "{{ working_dir }}/{{ llvm_version }}.tar.gz"
12+
dest: "{{ working_dir }}"
13+
remote_src: yes
14+
when: download_llvm.changed
15+
16+
- name: Move LLVM ({{ llvm_version }})
17+
command: mv {{ working_dir }}/{{ llvm_path }} {{ llvm_dir }}
18+
args:
19+
creates: "{{ llvm_dir }}"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Install Python Packages
3+
pip:
4+
name:
5+
- lit
6+
- filecheck
7+
executable: pip3
8+
become: true

ci/helpers/package.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- name: Prepare Package
3+
make:
4+
target: package
5+
chdir: "{{ release_build_dir }}"
6+
7+
- name: Get the package name
8+
slurp:
9+
src: "{{ release_build_dir }}/PACKAGE_FILE_NAME"
10+
register: package_file_name
11+
12+
- name: Prepare package dir
13+
file:
14+
path: /tmp/packages
15+
state: directory
16+
17+
- name: Copy package
18+
copy:
19+
src: "{{ release_build_dir }}/{{ package_file_name['content'] | b64decode }}.zip"
20+
dest: /tmp/packages/
21+
remote_src: true

ci/helpers/run-tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- name: Run Integration Tests ({{ build_type }})
3+
command: make graphml-integration-tests
4+
args:
5+
chdir: "{{ build_dir }}"

ci/helpers/variables.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
repo_url: [email protected]:ShiftLeftSecurity/llvm2graphml.git
3+
llvm_version: 9.0.0
4+
5+
llvm2cpg_cxx_flags: ""
6+
7+
working_dir: /opt
8+
gitref: master
9+
10+
llvm_mapping:
11+
ubuntu:
12+
9.0.0:
13+
url: http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
14+
path: clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04
15+
macos:
16+
9.0.0:
17+
url: http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-darwin-apple.tar.xz
18+
path: clang+llvm-9.0.0-x86_64-darwin-apple
19+
20+
llvm_url: "{{ llvm_mapping[platform][llvm_version].url }}"
21+
llvm_path: "{{ llvm_mapping[platform][llvm_version].path }}"
22+
llvm_dir: "{{ working_dir }}/llvm-{{ llvm_version }}"
23+
24+
gremlin_url: https://downloads.apache.org/tinkerpop/3.4.6/apache-tinkerpop-gremlin-console-3.4.6-bin.zip
25+
gremlin_dir: "{{ working_dir }}/apache-tinkerpop-gremlin-console-3.4.6"
26+
27+
source_dir: "{{ working_dir }}/llvm2graphml"
28+
debug_build_dir: "{{ working_dir }}/build.llvm2graphml.debug.dir"
29+
release_build_dir: "{{ working_dir }}/build.llvm2graphml.release.dir"

0 commit comments

Comments
 (0)