Merge pull request #44 from icatproject/dependabot/github_actions/act… #114
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 | |
with: | |
distribution: 'temurin' | |
java-version: ${{ matrix.java_version }} | |
- name: Cache local Maven repository | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
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@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | |
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 "[icatdb_minimal_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 Role | |
run: | | |
sed -i "/- role: icat_server$/a\ | |
\ - role: dev_common" icat-ansible/icatdb_minimal_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/icatdb_minimal_hosts.yml -i icat-ansible/hosts --vault-password-file icat-ansible/vault_pass.txt -vv | |
- name: Checkout authn-oidc | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | |
# 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 -DskipTests | |
- name: Run Unit Tests | |
run: mvn test -B | |
- name: After Failure | |
if: ${{ failure() }} | |
run: | | |
cat /home/runner/logs/authn_oidc.log | |
cat /home/runner/logs/icat.log | |
cat /home/runner/payara*/glassfish/domains/domain1/logs/server.log |