Skip to content

Commit

Permalink
rework test pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienDucourthial committed Nov 19, 2024
1 parent 81099df commit 95a1797
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 39 deletions.
32 changes: 13 additions & 19 deletions .github/workflows/run_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,23 @@ on:

jobs:
test:
runs-on: ${{ vars.RUNS_ON }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Install dependencies
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ansible
- name: Perform integration testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: stable-2.14
target-python-version: 3.9
testing-type: integration
test-deps: >-
community.crypto
pre-test-cmd: >-
echo "[endpoint: ${{ secrets.HORIZON_ENDPOINT }}, x_api_id: ${{ secrets.HORIZON_API_ID }}, x_api_key: ${{ secrets.HORIZON_API_KEY }}]" >> tests/integration/integration_config.yml
- name: Set integration_config.yml
run: >-
echo "[endpoint: ${{ secrets.HORIZON_ENDPOINT }}, x_api_id: ${{ secrets.HORIZON_API_ID }}, x_api_key: ${{ secrets.HORIZON_API_KEY }}]" >> tests/integration/integration_config.yml
- name: Perform unit testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: stable-2.14
target-python-version: 3.9
testing-type: units
- name: Run tests
run: make test
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
ANSIBLEGALAXYBUILD ?= ansible-galaxy
ANSIBLEGALAXYOPTS ?= --token="$(ANSIBLE_GALAXY_API_TOKEN)"
ANTSIBULLBUILD ?= antsibull-docs
ANTSIBULLOPTS ?=
ANTSIBULLOPTS ?=
SPHINXBUILD ?= sphinx-build
SPHINXOPTS ?=
ANSIBLETEST ?= ansible-test
COLLECTIONPATH ?= ~/.ansible/collections/ansible_collections/evertrust/horizon

.PHONY: docs

Expand All @@ -16,10 +18,20 @@ docs:
build: clean
@$(ANSIBLEGALAXYBUILD) "collection" "build" "--output-path=build/" $(ANSIBLEGALAXYPOTS)

install:
ARTIFACT=$$(find "build" -name "*.tar.gz" ); \
echo $$ARTIFACT; \
$(ANSIBLEGALAXYBUILD) "collection" "install" $$ARTIFACT

clean: ## Clean build artifacts
@rm -f build/*

publish: build ## Build and publish build artifact to Ansible Galaxy
ARTIFACT=$$(find "build" -name "*.tar.gz" ); \
echo $$ARTIFACT; \
$(ANSIBLEGALAXYBUILD) "collection" "publish" $$ARTIFACT $(ANSIBLEGALAXYOPTS)

test: build install
cd $(COLLECTIONPATH); \
$(ANSIBLETEST) "integration"; \
$(ANSIBLETEST) "units"
1 change: 1 addition & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ action_groups:
- horizon_feed
- horion_inventory
- horizon_lookup
- horizon_template
- horizon
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
cryptography>=3.5.0
pyjwt
pyjwt
requests
pytest-xdist
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

register: data

- copy: content="{{ data.certificate.certificate }}" dest="/PEM.pem"
- copy: content="{{ data.key }}" dest="/KEY.key"
- copy: content="{{ data.certificate.certificate }}" dest="/tmp/PEM.pem"
- copy: content="{{ data.key }}" dest="/tmp/KEY.key"

- name: Test centralize enrollment with unidentified profile
evertrust.horizon.horizon_enroll:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"
campaign: "Ansible"
ip: 0.0.0.1

Expand All @@ -19,7 +19,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"
ip: 0.0.0.1

ignore_errors: yes
Expand All @@ -41,7 +41,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"
campaign: "Ansible"

ignore_errors: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
endpoint: "{{ endpoint }}"
x_api_id: "{{ x_api_id }}"
x_api_key: "{{ x_api_key }}"

profile: "Ansible"
certificate_pem:
src: /tmp/importcertandkey.pem
Expand Down Expand Up @@ -47,6 +48,7 @@
endpoint: "{{ endpoint }}"
x_api_id: "{{ x_api_id }}"
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: /tmp/importkey.pem
campaign: "Ansible"
Expand All @@ -57,11 +59,12 @@
endpoint: "{{ endpoint }}"
x_api_id: "{{ x_api_id }}"
x_api_key: "{{ x_api_key }}"

profile: "Ansible"
certificate_id: "{{ cert_id._id }}"
private_key:
src: /tmp/importkey.key
vars:
certificate:
src: '/tmp/importkey.pem'
cert_id: "{{ lookup('evertrust.horizon.horizon_lookup', endpoint=endpoint, x_api_id=x_api_id, x_api_key=x_api_key, certificate_pem=certificate, fields='_id', wantlist=True) }}"
cert_id: "{{ lookup('evertrust.horizon.horizon_lookup', ca_bundle=ca_bundle, endpoint=endpoint, x_api_id=x_api_id, x_api_key=x_api_key, certificate_pem=certificate, fields='_id', wantlist=True) }}"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"

password: "Pass-W0rd"

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"

labels:
label-1: "retest"
Expand All @@ -22,7 +22,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"

labels:
label-1: "retest"
Expand All @@ -49,7 +49,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"

labels:
unexistantLabel: "retest"
Expand All @@ -73,9 +73,9 @@
endpoint: "{{endpoint }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"
private_key:
src: "/KEY.key"
src: "/tmp/KEY.key"

labels:
label-1: "test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"

revocation_reason: "unspecified"

Expand All @@ -19,7 +19,7 @@
x_api_key: "{{ x_api_key }}"

certificate_pem:
src: "/PEM.pem"
src: "/tmp/PEM.pem"

revocation_reason: "unspecified"

Expand Down Expand Up @@ -53,17 +53,17 @@

register: data

- copy: content="{{ data.certificate.certificate }}" dest="/PEM2.pem"
- copy: content="{{ data.key }}" dest="/KEY2.key"
- copy: content="{{ data.certificate.certificate }}" dest="/tmp/PEM2.pem"
- copy: content="{{ data.key }}" dest="/tmp/KEY2.key"

- name: Revoke a certificate by its file
evertrust.horizon.horizon_revoke:

endpoint: "{{ endpoint }}"

certificate_pem:
src: "/PEM2.pem"
src: "/tmp/PEM2.pem"
private_key:
src: "/KEY2.key"
src: "/tmp/KEY2.key"

revocation_reason: "unspecified"

0 comments on commit 95a1797

Please sign in to comment.