generated from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
odin: enable trivy and tf-lint scanning and pre-commit #72
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
Open
matt-mercer
wants to merge
6
commits into
main
Choose a base branch
from
mm-enable-trivy-and-tf-lint-scanning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
770c2dc
odin: enable trivy and tf-lint scanning and pre-commit
matt-mercer 6f472a5
odin: add in pr pipeline to check lint
matt-mercer 5845d15
odin: corrected target branch name
matt-mercer c0cd26e
odin: add lint-ci make target
matt-mercer 65f4f13
odin: add tf-lint init
matt-mercer c21be7b
odin: re-add region and ignore
matt-mercer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: "asdf-cache" | ||
| description: "asdf cache action from https://github.com/ai/asdf-cache-action/blob/main/action.yml" | ||
| inputs: | ||
| asdf-version: | ||
| description: "asdf version to install" | ||
| default: "" | ||
| required: false | ||
| os: | ||
| description: "target os" | ||
| default: "linux" | ||
| required: false | ||
| architecture: | ||
| description: "target architecture" | ||
| default: "amd64" | ||
| required: false | ||
| runs: | ||
| using: "composite" | ||
| steps: | ||
|
|
||
| - name: install asdf | ||
| shell: bash | ||
| run: | | ||
| set -o pipefail | ||
| asdf_version="${{ inputs.asdf-version }}" | ||
| asdf_version="$(echo "${asdf_version}" | sed 's#v##g')" | ||
| if which asdf && [[ "${asdf_version}" == "" || "$(asdf --version | cut -d' ' -f3)" == "v${asdf_version}" ]]; then | ||
| echo "asdf: $(asdf --version | cut -d' ' -f3) detected" | ||
| else | ||
| if [[ "${asdf_version}" == "" ]]; then | ||
| asdf_version="$(curl --fail -s "${GITHUB_API_URL}/repos/asdf-vm/asdf/releases/latest" | jq -r '.name')" | ||
| fi | ||
| asdf_version="$(echo "${asdf_version}" | sed 's#v##g')" | ||
| echo "installing asdf ${asdf_version}" | ||
| wget -q -O - "https://github.com/asdf-vm/asdf/releases/download/v${asdf_version}/asdf-v${asdf_version}-${{ inputs.os }}-${{ inputs.architecture }}.tar.gz" | tar -zxf - -C /usr/local/bin asdf | ||
| fi | ||
|
|
||
| - name: Cache asdf | ||
| id: cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.asdf | ||
| key: asdf-${{ hashFiles('**/.tool-versions') }} | ||
|
|
||
| - name: install asdf plugins | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| shell: bash | ||
| run: | | ||
| for plugin in $(cat .tool-versions | grep -Ev '^#' | cut -d' ' -f1 | uniq); do | ||
| asdf plugin add $plugin | ||
| done | ||
|
|
||
| - name: asdf install | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| shell: bash | ||
| run: | | ||
| asdf install | ||
|
|
||
| - name: update path | ||
| shell: bash | ||
| run: | | ||
| echo "${HOME}/.asdf/shims" >> $GITHUB_PATH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| name: "common-build-steps" | ||
| description: "regular build steps" | ||
| inputs: | ||
| python-version: | ||
| description: "If set, will use a system python version rather than asdf. Eg. a value of 3.11 would use the latest 3.11.x version. Set to empty string to use asdf versions." | ||
| default: "3.11" | ||
| required: false | ||
| fetch-depth: | ||
| description: "git fetch depth" | ||
| default: "0" | ||
| required: false | ||
|
|
||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: checkout the calling repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: ${{ inputs.fetch-depth }} | ||
|
|
||
| - name: setup python | ||
| if: ${{ inputs.python-version != '' }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
|
|
||
| - name: print branch info | ||
| shell: bash | ||
| run: | | ||
| git branch | ||
| echo "GITHUB_HEAD_REF=${GITHUB_HEAD_REF}" | ||
| echo "GITHUB_BASE_REF=${GITHUB_BASE_REF}" | ||
| git log --oneline -n 10 | ||
|
|
||
| - name: clean | ||
| shell: bash | ||
| run: | | ||
| git clean -fdx | ||
|
|
||
| - name: check secrets | ||
| uses: ./.github/actions/check-secrets | ||
|
|
||
| - name: merge into base_branch | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| shell: bash | ||
| run: | | ||
| echo base branch "${{ github.base_ref }}" | ||
| echo pr branch "${{ github.head_ref }}" | ||
| git checkout "${{ github.base_ref }}" | ||
| git checkout -b "merging-${{ github.event.number }}" | ||
| git merge --ff-only "${{ github.event.pull_request.head.sha }}" | ||
|
|
||
| - name: git reset | ||
| shell: bash | ||
| run: git reset --hard | ||
|
|
||
| - name: replace asdf python version | ||
| if: ${{ inputs.python-version != '' }} | ||
| shell: bash | ||
| run: sed -i -E 's#^python .*##g' .tool-versions | ||
|
|
||
| - name: Install tools from asdf config | ||
| if: ${{ hashFiles('**/.tool-versions') }} | ||
| uses: ./.github/actions/asdf-cache | ||
|
|
||
| - name: cache virtualenv | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| .venv | ||
| **/.lock-hash | ||
| **/requirements.txt | ||
| key: ${{ runner.os }}-py-${{ inputs.python-version }}-poetry-${{ hashFiles('./poetry.lock') }} | ||
|
|
||
| - name: fix virtualenv | ||
| shell: bash | ||
| run: | | ||
| if [ -d .venv/bin ]; then | ||
| echo fixing .venv | ||
| unlink .venv/bin/python3 | ||
| py_version="$(ls /opt/hostedtoolcache/Python --color=no | sed 's#/##g' | grep -E '^3.11' | sort -t\. -k3 --numeric | tail -n 1)" | ||
| if [ -z "${py_version}" ]; then | ||
| ls /opt/hostedtoolcache/Python | ||
| echo "could not find a compatible python version for ${py_version}" | ||
| exit -1 | ||
| fi | ||
| ln -s -t .venv/bin "/opt/hostedtoolcache/Python/${py_version}/x64/bin/python3" | ||
| find .venv/bin -type f -exec file {} + | awk -F: '/ASCII text/ {print $1}' | xargs grep -lr '.venv' | xargs sed -i -E "s#/.*?/.venv#${GITHUB_WORKSPACE}/.venv#" | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: "CI stages" | ||
| description: "run any standard CI stages found in the root Makefile" | ||
|
|
||
| inputs: | ||
| scan-type: | ||
| description: secrets scan type recursive/untracked etc. | ||
| default: 'recursive' | ||
| required: false | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: run git-secrets | ||
| shell: bash | ||
| run: | | ||
| export PATH="${PATH}:${{ github.action_path }}" | ||
| git secrets --register-aws | ||
| if [[ -e ./.gitdisallowed ]]; then | ||
| git secrets --add-provider -- grep -Ev '^(#.*|\s*$)' .gitdisallowed || true | ||
| git secrets --add --allowed '^.gitdisallowed:[0-9]+:.*' || true | ||
| fi | ||
| git secrets --scan --${{ inputs.scan-type }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.