|
| 1 | +name: 'Continuous Integration' |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: 'ci-${{ github.repository_id }}' |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + |
| 9 | + schedule: |
| 10 | + - cron: '30 1,13 * * 1-5' # At minute 30 past hour 1 and 13 on every day-of-week from Monday through Friday |
| 11 | + |
| 12 | +jobs: |
| 13 | + |
| 14 | + static_application_security_testing: |
| 15 | + |
| 16 | + name: 'Static Application Security Testing (SAST)' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + actions: read |
| 22 | + |
| 23 | + steps: |
| 24 | + |
| 25 | + - name: 'Set up steps' |
| 26 | + id: setup |
| 27 | + run: | |
| 28 | + echo "::set-output name=repository::$( echo "${{ github.repository }}" )" |
| 29 | + echo "::set-output name=repository_owner::$( echo "${{ github.repository_owner }}" )" |
| 30 | + echo "::set-output name=repository_name::$( echo "${{ github.event.repository.name }}" )" |
| 31 | + echo "::set-output name=branch::$( echo "${{ github.event.repository.default_branch }}" )" |
| 32 | + shell: bash |
| 33 | + |
| 34 | + - name: 'Check out repository' |
| 35 | + id: checkout |
| 36 | + uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + ref: '${{ steps.setup.outputs.branch }}' |
| 39 | + |
| 40 | + - name: 'Set up python' |
| 41 | + id: python |
| 42 | + uses: actions/setup-python@v4 |
| 43 | + with: |
| 44 | + token: '${{ secrets.GITHUB_TOKEN }}' |
| 45 | + python-version: '3.9' |
| 46 | + cache: 'pip' |
| 47 | + cache-dependency-path: 'requirements-dev.txt' |
| 48 | + |
| 49 | + - name: 'Install requirements' |
| 50 | + id: requirements |
| 51 | + run: pip install --exists-action w --requirement "requirements-dev.txt" |
| 52 | + shell: bash |
| 53 | + |
| 54 | + - name: 'Check code with black' |
| 55 | + id: black |
| 56 | + run: black --target-version py39 --line-length 120 --check . |
| 57 | + shell: bash |
| 58 | + |
| 59 | + # - name: 'Check code with cspell' |
| 60 | + # id: cspell |
| 61 | + # uses: check-spelling/[email protected] |
| 62 | + # with: |
| 63 | + # event_aliases: '{"workflow_dispatch":"push"}' |
| 64 | + # spell_check_this: check-spelling/spell-check-this@main |
| 65 | + # only_check_changed_files: false |
| 66 | + # check_extra_dictionaries: true |
| 67 | + # extra_dictionary_limit: 25 |
| 68 | + # extra_dictionaries: |
| 69 | + # cspell:en_US/en_US.txt |
| 70 | + # cspell:en_US/hyphenated-words.txt |
| 71 | + # cspell:pt_PT/Portuguese-European.txt |
| 72 | + # cspell:software-terms/software-terms.txt |
| 73 | + # cspell:software-terms/software-tools.txt |
| 74 | + # cspell:software-terms/network-protocols.txt |
| 75 | + # cspell:software-terms/network-os.txt |
| 76 | + # cspell:public-licenses/public-licenses.txt |
| 77 | + # cspell:public-licenses/additional-licenses.txt |
| 78 | + # cspell:companies/companies.txt |
| 79 | + # cspell:aws/aws.txt |
| 80 | + # cspell:docker/docker-words.txt |
| 81 | + # cspell:git/git.txt |
| 82 | + # cspell:django/django.txt |
| 83 | + # cspell:npm/npm.txt |
| 84 | + # cspell:bash/bash-words.txt |
| 85 | + # cspell:python/python.txt |
| 86 | + # cspell:python/python-lib.txt |
| 87 | + # cspell:python/extra.txt |
| 88 | + # cspell:python/additional_words.txt |
| 89 | + # cspell:typescript/typescript.txt |
| 90 | + # cspell:html/html.txt |
| 91 | + # cspell:html-symbol-entities/entities.txt |
| 92 | + # cspell:css/css.txt |
| 93 | + # cspell:filetypes/filetypes.txt |
| 94 | + |
| 95 | + unit_testing: |
| 96 | + |
| 97 | + name: 'Unit Testing' |
| 98 | + runs-on: ubuntu-latest |
| 99 | + |
| 100 | + permissions: |
| 101 | + contents: read |
| 102 | + actions: read |
| 103 | + |
| 104 | + steps: |
| 105 | + |
| 106 | + - name: 'Set up steps' |
| 107 | + id: setup |
| 108 | + run: | |
| 109 | + echo "::set-output name=repository::$( echo "${{ github.repository }}" )" |
| 110 | + echo "::set-output name=repository_owner::$( echo "${{ github.repository_owner }}" )" |
| 111 | + echo "::set-output name=repository_name::$( echo "${{ github.event.repository.name }}" )" |
| 112 | + echo "::set-output name=branch::$( echo "${{ github.event.repository.default_branch }}" )" |
| 113 | + shell: bash |
| 114 | + |
| 115 | + - name: 'Check out repository' |
| 116 | + id: checkout |
| 117 | + uses: actions/checkout@v3 |
| 118 | + with: |
| 119 | + ref: '${{ steps.setup.outputs.branch }}' |
| 120 | + |
| 121 | + - name: 'Set up python' |
| 122 | + id: python |
| 123 | + uses: actions/setup-python@v4 |
| 124 | + with: |
| 125 | + token: '${{ secrets.GITHUB_TOKEN }}' |
| 126 | + python-version: '3.9' |
| 127 | + cache: 'pip' |
| 128 | + cache-dependency-path: 'requirements-dev.txt' |
| 129 | + |
| 130 | + - name: 'Install requirements' |
| 131 | + id: requirements |
| 132 | + run: pip install --exists-action w --requirement "requirements-dev.txt" |
| 133 | + shell: bash |
| 134 | + |
| 135 | + dynamic_application_security_testing: |
| 136 | + |
| 137 | + name: 'Dynamic Application Security Testing (DAST)' |
| 138 | + runs-on: ubuntu-latest |
| 139 | + |
| 140 | + permissions: |
| 141 | + contents: read |
| 142 | + actions: read |
| 143 | + |
| 144 | + steps: |
| 145 | + |
| 146 | + - name: 'Set up steps' |
| 147 | + id: setup |
| 148 | + run: | |
| 149 | + echo "::set-output name=repository::$( echo "${{ github.repository }}" )" |
| 150 | + echo "::set-output name=repository_owner::$( echo "${{ github.repository_owner }}" )" |
| 151 | + echo "::set-output name=repository_name::$( echo "${{ github.event.repository.name }}" )" |
| 152 | + echo "::set-output name=branch::$( echo "${{ github.event.repository.default_branch }}" )" |
| 153 | + shell: bash |
| 154 | + |
| 155 | + - name: 'Check out repository' |
| 156 | + id: checkout |
| 157 | + uses: actions/checkout@v3 |
| 158 | + with: |
| 159 | + ref: '${{ steps.setup.outputs.branch }}' |
| 160 | + |
| 161 | + - name: 'Get build version' |
| 162 | + id: versioning |
| 163 | + uses: ./.github/actions/get-build-version |
| 164 | + with: |
| 165 | + file: '__init__.py' |
| 166 | + |
| 167 | + - name: 'Build docker image' |
| 168 | + id: docker |
| 169 | + uses: ./.github/actions/build-docker-image |
| 170 | + with: |
| 171 | + name: '${{ steps.setup.outputs.repository }}' |
| 172 | + tag: '${{ steps.versioning.outputs.version }}' |
| 173 | + dockerfile: 'Dockerfile' |
| 174 | + archive: '${{ steps.setup.outputs.repository_name }}-docker.tar.gz' |
| 175 | + |
| 176 | + report: |
| 177 | + |
| 178 | + name: 'Report' |
| 179 | + runs-on: ubuntu-latest |
| 180 | + |
| 181 | + needs: [static_application_security_testing, unit_testing, dynamic_application_security_testing] |
| 182 | + |
| 183 | + if: ${{ always() }} |
| 184 | + |
| 185 | + permissions: |
| 186 | + contents: read |
| 187 | + actions: read |
| 188 | + |
| 189 | + steps: |
| 190 | + |
| 191 | + - name: 'Set up steps' |
| 192 | + id: setup |
| 193 | + run: | |
| 194 | + echo "::set-output name=repository::$( echo "${{ github.repository }}" )" |
| 195 | + echo "::set-output name=repository_owner::$( echo "${{ github.repository_owner }}" )" |
| 196 | + echo "::set-output name=repository_name::$( echo "${{ github.event.repository.name }}" )" |
| 197 | + echo "::set-output name=branch::$( echo "${{ github.event.repository.default_branch }}" )" |
| 198 | + echo "::set-output name=channel::$( echo "#development" )" |
| 199 | + shell: bash |
| 200 | + |
| 201 | + - name: 'Check out repository' |
| 202 | + id: checkout |
| 203 | + uses: actions/checkout@v3 |
| 204 | + with: |
| 205 | + ref: '${{ steps.setup.outputs.branch }}' |
| 206 | + |
| 207 | + - name: 'Get build version' |
| 208 | + id: versioning |
| 209 | + uses: ./.github/actions/get-build-version |
| 210 | + with: |
| 211 | + file: '__init__.py' |
| 212 | + |
| 213 | + - name: 'Get workflow status' |
| 214 | + id: workflow |
| 215 | + uses: martialonline/workflow-status@v3 |
| 216 | + |
| 217 | + - name: Notify channel '#${{ steps.setup.outputs.channel }}' |
| 218 | + id: notify |
| 219 | + if: ${{ always() && (steps.workflow.outputs.status == 'failure') }} |
| 220 | + |
| 221 | + env: |
| 222 | + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL }}' |
| 223 | + with: |
| 224 | + channel: '${{ steps.setup.outputs.channel }}' |
| 225 | + status: '${{ steps.workflow.outputs.status }}' |
| 226 | + success_text: ' [*SUCCESS*] <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }} (${{ steps.setup.outputs.repository }})>' |
| 227 | + failure_text: ' [*FAILURE*] <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }} (${{ steps.setup.outputs.repository }})>' |
| 228 | + cancelled_text: '[*CANCELLED*] <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }} (${{ steps.setup.outputs.repository }})>' |
| 229 | + fields: | |
| 230 | + [ |
| 231 | + { "title": "Version", "value": "${{ steps.versioning.outputs.version }}", "short": true } |
| 232 | + ,{ "title": "Branch", "value": "<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.setup.outputs.branch }}>", "short": true } |
| 233 | + ] |
0 commit comments