feat(workflow): add EULA acceptance to CI pipeline #185
Workflow file for this run
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: Module Test | |
on: | |
push: | |
pull_request: | |
types: | |
- review_requested | |
workflow_dispatch: | |
jobs: | |
module: | |
name: Sanity & Unit Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: | | |
3.8 | |
3.9 | |
3.10 | |
3.11 | |
3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
# Install the local collection | |
ansible-galaxy collection install . --force | |
- name: Run Sanity Tests | |
run: | | |
cd /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus | |
ansible-test sanity plugins/modules/ plugins/module_utils/ tests/ --docker default | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
- name: Run Unit tests | |
run: | | |
cd /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus | |
ansible-test units --docker default --coverage | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
- name: Generate code coverage report | |
run: | | |
cd /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus | |
ansible-test coverage xml | |
- name: Copy test output files | |
run: | | |
mkdir -p /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output | |
cp -r /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus/tests/output/* /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/ | |
mv /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/junit/python3.10-modules-units.xml /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/junit/python3.10-modules.junit.xml | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: unit-test-results | |
path: | | |
/home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output | |
retention-days: 5 | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
fail_ci_if_error: true | |
directory: /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/junit/ | |
files: python3.10-modules.junit.xml | |
flags: python3.10 | |
#disable_search: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
- name: Upload test results to Codecov root | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
fail_ci_if_error: true | |
directory: /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/junit/ | |
files: python3.10-modules.junit.xml | |
flags: python3.10 | |
#disable_search: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
- name: Upload coverage to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/codecov-action@v5 | |
with: | |
fail_ci_if_error: true | |
directory: /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/ | |
files: reports/coverage.xml | |
slug: CloudKrafter/nexus-ansible-collection | |
flags: unittests | |
token: ${{ secrets.CODECOV_TOKEN }} | |
integration: | |
name: Integration Tests | |
runs-on: ubuntu-latest | |
needs: module | |
services: | |
nexus: | |
image: sonatype/nexus3:latest | |
ports: | |
- 8081:8081 | |
# options: >- | |
# --health-cmd "curl -f http://localhost:8081/service/rest/v1/status" | |
# --health-interval 30s | |
# --health-timeout 10s | |
# --health-retries 5 | |
# --health-start-period 60s | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
ansible-galaxy collection install . --force | |
- name: Run integration tests | |
run: | | |
cd /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus | |
ansible-test integration download --docker default --coverage --continue-on-error -v | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
- name: Wait for Nexus startup | |
run: | | |
timeout 300 bash -c 'until curl -f http://localhost:8081/service/rest/v1/status; do sleep 5; done' | |
- name: Change initial admin password | |
run: | | |
ADMIN_PASS=$(docker exec $(docker ps -q) cat /nexus-data/admin.password) | |
curl -u admin:$ADMIN_PASS -X PUT http://localhost:8081/service/rest/v1/security/users/admin/change-password -H "accept: application/json" -H "Content-Type: text/plain" -d "changeme" | |
- name: Get EULA disclaimer | |
run: | | |
sudo apt-get update && sudo apt-get install -y jq | |
DISCLAIMER=$(curl -s http://localhost:8081/service/rest/v1/system/eula \ | |
-H 'accept: application/json' \ | |
-u admin:changeme | jq -r '.disclaimer') | |
echo "EULA_DISCLAIMER=$DISCLAIMER" >> $GITHUB_ENV | |
- name: Accept EULA | |
run: | | |
curl -X POST \ | |
'http://localhost:8081/service/rest/v1/system/eula' \ | |
-H 'accept: application/json' \ | |
-H 'Content-Type: application/json' \ | |
-u admin:changeme \ | |
-d "{ | |
\"accepted\": true, | |
\"disclaimer\": \"$EULA_DISCLAIMER\" | |
}" | |
- name: Create raw repository | |
run: | | |
curl -X POST \ | |
'http://localhost:8081/service/rest/v1/repositories/raw/hosted' \ | |
-H 'accept: application/json' \ | |
-H 'Content-Type: application/json' \ | |
-u admin:changeme \ | |
-d '{ | |
"name": "raw-hosted", | |
"online": true, | |
"storage": { | |
"blobStoreName": "default", | |
"strictContentTypeValidation": true, | |
"writePolicy": "ALLOW" | |
}, | |
"cleanup": { | |
"policyNames": [] | |
}, | |
"component": { | |
"proprietaryComponents": false | |
}, | |
"raw": { | |
"contentDisposition": "ATTACHMENT" | |
} | |
}' | |
- name: Run integration tests | |
run: | | |
cd /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus | |
ansible-test integration raw_component --coverage --continue-on-error -v | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
- name: Generate code coverage report | |
run: | | |
cd /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus | |
ansible-test coverage xml | |
- name: Copy test output files | |
run: | | |
mkdir -p /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output | |
cp -r /home/runner/.ansible/collections/ansible_collections/cloudkrafter/nexus/tests/output/* /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/ | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: integration-test-results | |
path: | | |
/home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output | |
retention-days: 5 | |
- name: Upload coverage to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/codecov-action@v5 | |
with: | |
fail_ci_if_error: true | |
directory: /home/runner/work/nexus-ansible-collection/nexus-ansible-collection/tests/output/ | |
# files: reports/coverage.xml | |
slug: CloudKrafter/nexus-ansible-collection | |
flags: integrationtests | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Collect Nexus logs on failure | |
if: failure() | |
run: | | |
mkdir -p /tmp/nexus-logs | |
docker cp $(docker ps -q):/nexus-data/log/ /tmp/nexus-logs/ | |
- name: Upload Nexus logs | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nexus-logs | |
path: /tmp/nexus-logs | |
retention-days: 5 |