-
Notifications
You must be signed in to change notification settings - Fork 4
116 lines (101 loc) · 4.13 KB
/
ci-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: CI Build
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
jobs:
build_and_tests:
runs-on: ubuntu-22.04
strategy:
matrix:
java_version: [11, 17]
steps:
# Setup Java & Python
- name: Setup Java
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
- name: Cache local Maven repository
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run apt-get update
run: sudo apt-get update
# ICAT Ansible clone and install dependencies
- name: Checkout icat-ansible
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
repository: icatproject-contrib/icat-ansible
path: icat-ansible
ref: master
- name: Install Ansible
run: pip install -r icat-ansible/requirements.txt
# Prep for running the playbook
- name: Create Hosts File
run: echo -e "[icat_server_dev_hosts]\nlocalhost ansible_connection=local" > icat-ansible/hosts
- name: Prepare vault pass
run: echo -e "icattravispw" > icat-ansible/vault_pass.txt
- name: Move vault to directory it'll get detected by Ansible
run: mv icat-ansible/vault.yml icat-ansible/group_vars/all
- name: Replace default payara user with Actions user
run: |
sed -i -e "s/^payara_user: \"glassfish\"/payara_user: \"runner\"/" icat-ansible/group_vars/all/vars.yml
- name: Add Ansible roles
run: |
sed -i "s/- role: icat_lucene/- role: icat_server\\
\ - role: ids_storage_file/g" icat-ansible/icat_server_dev_hosts.yml
# Force hostname to localhost - bug fix for previous ICAT Ansible issues on Actions
- name: Change hostname to localhost
run: sudo hostname -b localhost
# Remove existing MySQL installation so it doesn't interfere with GitHub Actions
- name: Remove existing mysql
run: |
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
sudo apt-get remove --purge "mysql*"
sudo rm -rf /var/lib/mysql* /etc/mysql
# Create local instance of ICAT
- name: Run ICAT Ansible Playbook
run: |
ansible-playbook icat-ansible/icat_server_dev_hosts.yml -i icat-ansible/hosts --vault-password-file icat-ansible/vault_pass.txt -vv
# Prep for the integration tests
- name: Checkout ids-storage-test
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
repository: icatproject/ids.storage_test
path: ids.storage_test
ref: master
- name: Install ids-storage-test
run: |
cd ids.storage_test
mvn package
unzip target/ids.storage_test-*.zip
cd ids.storage_test
cp setup.properties.example setup.properties
sed -i 's+home=/home/fisher/pf/glassfish4+home='"$(realpath /home/runner/payara*)+g" setup.properties
./setup -vv install
- name: Checkout ids-server
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
# Payara must be sourced otherwise the Maven build command fails
- name: Run Build
run: |
grep payara ~/.bash_profile > payara_path_command
source payara_path_command
mvn install -B -DskipTests
- name: Run Unit Tests
run: mvn test -B
# failsafe:integration-test to run the integration tests
# failsafe:verify required to check for test failures
- name: Run Integration Tests
run: mvn failsafe:integration-test failsafe:verify -B
- name: After Failure
if: ${{ failure() }}
run: |
cat /home/runner/logs/ids.log
cat /home/runner/logs/icat.log
cat /home/runner/payara*/glassfish/domains/domain1/logs/server.log