Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust CircleCI config to make it work on cisco-en-programmability #4

Merged
merged 13 commits into from
Sep 27, 2024
48 changes: 32 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
pre:
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main

steps:
- run:
Expand All @@ -93,7 +93,7 @@ jobs:
build:
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main
steps:
- run:
name: Debug information
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
default: false
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main

steps:
- run:
Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:
sanity-tests:
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main
parallelism: 4
steps:
- when:
Expand Down Expand Up @@ -343,8 +343,16 @@ jobs:
chmod 600 ~/id_ssh
export NO_PROXY=""
export no_proxy=""
ssh $LOGS_MACHINE -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/id_ssh mkdir -p /var/www/html/madhan-logs/$CIRCLE_BUILD_NUM
scp -i ~/id_ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sanity_tests_logs_$CIRCLE_NODE_INDEX $LOGS_MACHINE:/var/www/html/madhan-logs/$CIRCLE_BUILD_NUM
ssh $LOGS_MACHINE \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-i ~/id_ssh \
mkdir -p /var/www/html/madhan-logs/$CIRCLE_BUILD_NUM
scp \
-i ~/id_ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
sanity_tests_logs_$CIRCLE_NODE_INDEX $LOGS_MACHINE:/var/www/html/madhan-logs/$CIRCLE_BUILD_NUM
echo "LOGS URL: http://10.195.243.37/madhan-logs/$CIRCLE_BUILD_NUM/sanity_tests_logs_$CIRCLE_NODE_INDEX"
if [[ $(cat rc) != "0" ]]; then exit 1; fi

Expand All @@ -353,7 +361,7 @@ jobs:
post_pnp_testing:
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main

steps:
- when:
Expand All @@ -366,7 +374,7 @@ jobs:
main-pr:
docker:
- image: maniator/gh:v2.49.2
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main
steps:
- run:
name: Clone repo to workspace
Expand All @@ -375,12 +383,16 @@ jobs:
name: Create release pr to main
command: |
gh repo set-default $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
gh pr create --base main --head $CIRCLE_BRANCH --title "Release v<< pipeline.parameters.ansible_cisco_dnac_version >>" --body "Release v<< pipeline.parameters.ansible_cisco_dnac_version >>"
gh pr create \
--base main \
--head $CIRCLE_BRANCH \
--title "Release v<< pipeline.parameters.ansible_cisco_dnac_version >>" \
--body "Release v<< pipeline.parameters.ansible_cisco_dnac_version >>"

release-job:
docker:
- image: python:3.8.10
resource_class: cisco-en-programmability/dnacenter-ansible
resource_class: cisco-en-programmability/catalyst-center-ansible-runner-main
steps:
- run:
name: Clone repo to workspace
Expand All @@ -396,8 +408,12 @@ jobs:
# - "KEY_FINGERPRINT"
- run:
echo create release
# git tag -a v<< pipeline.parameters.ansible_cisco_dnac_version >> -m "Ansible DNACCollection Version v<< pipeline.parameters.ansible_cisco_dnac_version >>"
# gh release create "v<< pipeline.parameters.ansible_cisco_dnac_version >>" --title "DNAC Collection Version v<< pipeline.parameters.ansible_cisco_dnac_version >>" --latest
# git tag \
# -a v<< pipeline.parameters.ansible_cisco_dnac_version >> \
# -m "Ansible DNACCollection Version v<< pipeline.parameters.ansible_cisco_dnac_version >>"
# gh release create "v<< pipeline.parameters.ansible_cisco_dnac_version >>" \
# --title "DNAC Collection Version v<< pipeline.parameters.ansible_cisco_dnac_version >>" \
# --latest
# ansible-galaxy collection publish workspace/*.tar.gz --api-key=$GALAXYKEY

workflows:
Expand All @@ -406,9 +422,9 @@ workflows:
when:
and:
- or:
- equal: [run-tests, << pipeline.parameters.GHA_Meta >>]
# - equal: [true, << pipeline.parameters.run-setup >>]
- not: << pipeline.parameters.continued >>
- equal: [run-tests, << pipeline.parameters.GHA_Meta >>]
# - equal: [true, << pipeline.parameters.run-setup >>]
- not: << pipeline.parameters.continued >>
jobs:
- pre

Expand Down Expand Up @@ -515,4 +531,4 @@ workflows:
- build
context:
- gh-token
- galaxy-token
- galaxy-token
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
merge-method: rebase
do-not-merge-labels: never-merge
# pull-request: ${{ github.event.inputs.pull-request }}
dry-run: false
dry-run: false
4 changes: 3 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
rm -rf $(basename ${GITHUB_REF})
mv docs/_build/html $(basename ${GITHUB_REF})
git show origin/main:docs/_gh_include/header.inc > index.html
(echo main; dirname v*/index.html | sort --version-sort --reverse) | xargs -I@@ -n1 echo '<div class="col-md-4 center"><a href="@@/" class="btn-doc btn"><i class="fa fa-newspaper-o"></i><p>@@</p></a></div>' >> index.html
(echo main; dirname v*/index.html | sort --version-sort --reverse) \
| xargs -I@@ \
-n1 echo '<div class="col-md-4 center"><a href="@@/" class="btn-doc btn"><i class="fa fa-newspaper-o"></i><p>@@</p></a></div>' >> index.html
git show origin/main:docs/_gh_include/footer.inc >> index.html
git add $(basename ${GITHUB_REF}) index.html
git commit -m "update docs for $(basename ${GITHUB_REF})" || true
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
runs-on: ubuntu-20.04
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/download-artifact@v4
with:
name: github_ref-${{ github.event.workflow_run.id }}
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger circleci
run: |
printf '{"branch": "%s" ,"parameters": {"GHA_Meta":"run-tests"}}' $(cat github_ref) > req_body
curl -X POST --location "https://circleci.com/api/v2/project/gh/${{ github.repository }}/pipeline" \
-H "Content-Type: application/json" \
-H "Circle-Token: ${{ secrets.CCI_TOKEN }}" \
-d "@req_body"
- uses: actions/download-artifact@v4
with:
name: github_ref-${{ github.event.workflow_run.id }}
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger circleci
run: |
printf '{"branch": "%s" ,"parameters": {"GHA_Meta":"run-tests"}}' $(cat github_ref) > req_body
curl -X POST --location "https://circleci.com/api/v2/project/gh/${{ github.repository }}/pipeline" \
-H "Content-Type: application/json" \
-H "Circle-Token: ${{ secrets.CCI_TOKEN }}" \
-d "@req_body"
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: github_ref-${{ github.run_id }}
path: github_ref
path: github_ref
4 changes: 2 additions & 2 deletions .github/workflows/release-prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# push:
# branches:
# - '**-rc'

# jobs:
# trigger-circleci:
# runs-on: ubuntu-20.04
Expand All @@ -14,4 +14,4 @@
# with:
# GHA_Meta: "run-release-prep"
# env:
# CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
# CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# with:
# GHA_Meta: "run-release"
# env:
# CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
# CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
9 changes: 6 additions & 3 deletions .github/workflows/sanity_tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
env:
NAMESPACE: cisco
COLLECTION_NAME: dnac
COLLECTION_NAME: dnac
jobs:
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix
# 2.14 supports Python 3.9-3.11
Expand Down Expand Up @@ -44,3 +43,7 @@ jobs:
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Install yamllint
run: pip install --user yamllint
- name: Rum yamllint
run: yamllint -c .yamllint.yml .
7 changes: 6 additions & 1 deletion .github/workflows/sanity_tests_devel.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: CI Devel
on:
workflow_dispatch:
pull_request:
env:
NAMESPACE: cisco
COLLECTION_NAME: dnac
COLLECTION_NAME: dnac
jobs:
sanity:
name: Sanity (Ⓐ${{ matrix.ansible }})
Expand All @@ -30,3 +31,7 @@ jobs:
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Install yamllint
run: pip install --user yamllint
- name: Rum yamllint
run: yamllint -c .yamllint.yml .
10 changes: 10 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
extends: default
rules:
line-length:
max: 160
ignore:
- tests
- changelogs/changelog.yaml
- playbooks
level: warning
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
requires_ansible: '>=2.15.0'
requires_ansible: '>=2.15.0'
1 change: 1 addition & 0 deletions plugins/module_utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class AnsibleDNACException(Exception):
class InconsistentParameters(AnsibleDNACException):
"""Provided parameters are not consistent."""
pass

2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ do
echo " - $role" >> ccc_test_roles.yml
done

ansible-playbook -i hosts ccc_test_roles.yml > "sanity_tests_logs_$CIRCLE_NODE_INDEX"
ansible-playbook -i hosts ccc_test_roles.yml #> "sanity_tests_logs_$CIRCLE_NODE_INDEX"
Loading