integration.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. name: Integration tests
  2. # Run this workflow every time a new commit pushed to your repository
  3. on:
  4. push:
  5. branches:
  6. - main
  7. pull_request_target:
  8. branches:
  9. - main
  10. workflow_dispatch: {}
  11. jobs:
  12. # Set the job key. The key is displayed as the job name
  13. # when a job name is not provided
  14. lint:
  15. name: Lint code
  16. runs-on: ubuntu-latest
  17. strategy:
  18. matrix:
  19. python-version: [ '3.10' ]
  20. steps:
  21. - name: Checkout code
  22. uses: actions/checkout@v4
  23. with:
  24. ref: ${{ github.event.pull_request.head.sha }}
  25. - name: Setup Python
  26. uses: actions/setup-python@v5
  27. with:
  28. python-version: ${{ matrix.python-version }}
  29. - name: Cache pip dir
  30. uses: actions/cache@v4
  31. with:
  32. path: ~/.cache/pip
  33. key: pip-cache-${{ matrix.python-version }}-lint
  34. - name: Install required packages
  35. run: pip install tox
  36. - name: Run tox
  37. run: tox -e lint
  38. integration:
  39. # Name the Job
  40. name: Per-cloud integration tests
  41. needs: lint
  42. # Set the type of machine to run on
  43. runs-on: ubuntu-latest
  44. permissions:
  45. id-token: write # required for AWS OIDC
  46. contents: read
  47. strategy:
  48. fail-fast: false
  49. matrix:
  50. python-version: ['3.10']
  51. cloud-provider: ['aws', 'azure', 'gcp', 'mock', 'openstack']
  52. steps:
  53. - name: Checkout code
  54. uses: actions/checkout@v4
  55. with:
  56. ref: ${{ github.event.pull_request.head.sha }}
  57. - name: Setup Python
  58. uses: actions/setup-python@v5
  59. with:
  60. python-version: ${{ matrix.python-version }}
  61. - name: Cache pip dir
  62. uses: actions/cache@v4
  63. with:
  64. path: ~/.cache/pip
  65. key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/setup.py', '**/requirements.txt') }}
  66. - name: Install required packages
  67. run: pip install tox
  68. - name: Configure AWS credentials via OIDC
  69. if: matrix.cloud-provider == 'aws'
  70. uses: aws-actions/configure-aws-credentials@v4
  71. with:
  72. role-to-assume: ${{ secrets.AWS_OIDC_ROLE_ARN }}
  73. aws-region: us-east-1
  74. - name: Run tox
  75. id: tox
  76. run: tox -e py${{ matrix.python-version }}-${{ matrix.cloud-provider }}
  77. env:
  78. PYTHONUNBUFFERED: "True"
  79. # aws — credentials provided by configure-aws-credentials step above (OIDC)
  80. CB_VM_TYPE_AWS: ${{ secrets.CB_VM_TYPE_AWS }}
  81. # azure
  82. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
  83. AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  84. AZURE_SECRET: ${{ secrets.AZURE_SECRET }}
  85. AZURE_TENANT: ${{ secrets.AZURE_TENANT }}
  86. AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
  87. AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
  88. CB_IMAGE_AZURE: ${{ secrets.CB_IMAGE_AZURE }}
  89. CB_VM_TYPE_AZURE: ${{ secrets.CB_VM_TYPE_AZURE }}
  90. # gcp
  91. GCP_SERVICE_CREDS_DICT: ${{ secrets.GCP_SERVICE_CREDS_DICT }}
  92. CB_IMAGE_GCP: ${{ secrets.CB_IMAGE_GCP }}
  93. CB_VM_TYPE_GCP: ${{ secrets.CB_VM_TYPE_GCP }}
  94. # openstack
  95. OS_AUTH_URL: ${{ secrets.OS_AUTH_URL }}
  96. OS_PASSWORD: ${{ secrets.OS_PASSWORD }}
  97. OS_PROJECT_NAME: ${{ secrets.OS_PROJECT_NAME }}
  98. OS_PROJECT_DOMAIN_NAME: ${{ secrets.OS_PROJECT_DOMAIN_NAME }}
  99. OS_TENANT_NAME: ${{ secrets.OS_TENANT_NAME }}
  100. OS_USERNAME: ${{ secrets.OS_USERNAME }}
  101. OS_REGION_NAME: ${{ secrets.OS_REGION_NAME }}
  102. OS_USER_DOMAIN_NAME: ${{ secrets.OS_USER_DOMAIN_NAME }}
  103. OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
  104. OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
  105. CB_IMAGE_OS: ${{ secrets.CB_IMAGE_OS }}
  106. CB_VM_TYPE_OS: ${{ secrets.CB_VM_TYPE_OS }}
  107. CB_PLACEMENT_OS: ${{ secrets.CB_PLACEMENT_OS }}
  108. - name: Create Build Status Badge
  109. if: github.ref == 'refs/heads/master'
  110. uses: schneegans/dynamic-badges-action@v1.1.0
  111. with:
  112. auth: ${{ secrets.BUILD_STATUS_GIST_SECRET }}
  113. gistID: ${{ secrets.BUILD_STATUS_GIST_ID }}
  114. filename: cloudbridge_py${{ matrix.python-version }}_${{ matrix.cloud-provider }}.json
  115. label: ${{ matrix.cloud-provider }}
  116. message: ${{ fromJSON('["passing", "failing"]')[steps.tox.outcome != 'success'] }}
  117. color: ${{ fromJSON('["green", "red"]')[steps.tox.outcome != 'success'] }}
  118. - name: Coveralls
  119. if: ${{ steps.tox.outcome == 'success' }}
  120. uses: AndreMiras/coveralls-python-action@develop
  121. with:
  122. github-token: ${{ secrets.GITHUB_TOKEN }}
  123. flag-name: run-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
  124. parallel: true
  125. finish:
  126. needs: integration
  127. runs-on: ubuntu-latest
  128. steps:
  129. - name: Coveralls Finished
  130. uses: AndreMiras/coveralls-python-action@develop
  131. with:
  132. github-token: ${{ secrets.github_token }}
  133. parallel-finished: true