|
| 1 | +name: Run unit tests |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + version: |
| 6 | + description: The version of fact to be tested (commit SHA or tag) |
| 7 | + default: ${{ github.head_ref || github.ref_name }} |
| 8 | + type: string |
| 9 | + job-tag: |
| 10 | + description: Additional tag to prevent collision on GCP VM naming |
| 11 | + type: string |
| 12 | + default: '-ut' |
| 13 | + |
| 14 | +jobs: |
| 15 | + unit-tests: |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + vm: |
| 21 | + - rhel |
| 22 | + - rhel-arm64 |
| 23 | + - rhcos |
| 24 | + - rhcos-arm64 |
| 25 | + - cos |
| 26 | + - cos-arm64 |
| 27 | + - flatcar |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + path: fact |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + repository: stackrox/collector |
| 36 | + path: collector |
| 37 | + ref: master |
| 38 | + - uses: actions/setup-python@v5 |
| 39 | + with: |
| 40 | + python-version: "3.10" |
| 41 | + |
| 42 | + - name: Authenticate with GCP |
| 43 | + uses: 'google-github-actions/auth@v2' |
| 44 | + with: |
| 45 | + credentials_json: '${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_CI_VM_SVC_ACCT }}' |
| 46 | + |
| 47 | + - name: Setup GCP |
| 48 | + uses: 'google-github-actions/setup-gcloud@v2' |
| 49 | + |
| 50 | + - uses: ./collector/.github/actions/setup-vm-creds |
| 51 | + with: |
| 52 | + gcp-ssh-key: ${{ secrets.GCP_SSH_KEY }} |
| 53 | + gcp-ssh-key-pub: ${{ secrets.GCP_SSH_KEY_PUB }} |
| 54 | + s390x-ssh-key: ${{ secrets.IBM_CLOUD_S390X_SSH_PRIVATE_KEY }} |
| 55 | + ppc64le-ssh-key: ${{ secrets.IBM_CLOUD_POWER_SSH_PRIVATE_KEY }} |
| 56 | + ppc64le-ssh-key-pub: ${{ secrets.IBM_CLOUD_POWER_SSH_PUBLIC_KEY }} |
| 57 | + s390x-key: ${{ secrets.IBM_CLOUD_S390x_API_KEY }} |
| 58 | + ppc64le-key: ${{ secrets.IBM_CLOUD_POWER_API_KEY }} |
| 59 | + redhat-username: ${{ secrets.REDHAT_USERNAME }} |
| 60 | + redhat-password: ${{ secrets.REDHAT_PASSWORD }} |
| 61 | + vm-type: ${{ matrix.vm }} |
| 62 | + job-tag: ${{ inputs.job-tag }} |
| 63 | + workspace: ${{ github.workspace }}/collector |
| 64 | + |
| 65 | + - name: Create vars.yml |
| 66 | + run: | |
| 67 | + cat << EOF > vars.yml |
| 68 | + --- |
| 69 | + job_id: ${JOB_ID} |
| 70 | + fact: |
| 71 | + version: ${{ inputs.version }} |
| 72 | + workdir: ${{ github.workspace }} |
| 73 | + excluded_vms: |
| 74 | + - rhel-8 |
| 75 | + - rhcos-412 |
| 76 | + EOF |
| 77 | +
|
| 78 | + - name: Create Test VMs |
| 79 | + run: | |
| 80 | + ansible-playbook \ |
| 81 | + make -C "./collector/ansible" create-ci-vms |
| 82 | +
|
| 83 | + - name: Run the tests |
| 84 | + run: | |
| 85 | + ansible-playbook \ |
| 86 | + -i "${GITHUB_WORKSPACE}/collector/ansible/ci" \ |
| 87 | + -e @vars.yml \ |
| 88 | + "${GITHUB_WORKSPACE}/fact/ansible/run-unit-tests.yml" |
| 89 | +
|
| 90 | + - name: Teardown VMs |
| 91 | + if: always() |
| 92 | + run: | |
| 93 | + make -C "./collector/ansible" destroy-vms |
| 94 | +
|
| 95 | + - name: Store artifacts |
| 96 | + if: always() |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: ${{ matrix.vm }}-unit-test-logs |
| 100 | + path: | |
| 101 | + ${{ github.workspace }}/unit-test-*.log |
| 102 | + if-no-files-found: ignore |
0 commit comments