diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index db726b0c..e871b3d4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -382,13 +382,67 @@ jobs: # Checkout DataGateway API and setup Python - name: Check out repo uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v3.5.3 + # Setup Java & Python - name: Setup Python uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 with: python-version: ${{ matrix.python-version }} architecture: x64 + - name: Setup Java + uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 + with: + distribution: 'temurin' + java-version: 8 + + # ICAT Ansible clone and install dependencies + - name: Checkout icat-ansible + if: success() + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + repository: icatproject-contrib/icat-ansible + ref: master + path: icat-ansible + - 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 + + # 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 + + # rootUserNames needs editing as anon/anon is used in search API and required to pass endpoint tests + - name: Add anon user to rootUserNames + run: | + awk -F" =" '/rootUserNames/{$2="= simple/root anon/anon";print;next}1' /home/runner/install/icat.server/run.properties > /home/runner/install/icat.server/run.properties.tmp + - name: Apply rootUserNames change + run: | + mv -f /home/runner/install/icat.server/run.properties.tmp /home/runner/install/icat.server/run.properties + - name: Reinstall ICAT Server + run: | + cd /home/runner/install/icat.server/ && ./setup -vv install - # Create virtual environment and install DataGateway API + # Create virtual environment and install DataGateway API - name: Create and activate virtual environment run: | python3 -m venv dg-api-venv @@ -407,9 +461,6 @@ jobs: '.datagateway_api.extension="/datagateway_api"' datagateway_api/config.yaml.example`" > datagateway_api/config.yaml.example - name: Create config.yaml run: cp datagateway_api/config.yaml.example datagateway_api/config.yaml - # These sections are removed so the API doesn't try to (and fail) to connect to an ICAT stack on startup - - name: Remove DataGateway API and Search API sections from config - run: yq -i 'del(.datagateway_api, .search_api)' datagateway_api/config.yaml - name: Create search_api_mapping.json run: cp datagateway_api/search_api_mapping.json.example datagateway_api/search_api_mapping.json