From 3e5a5db92f8c41c7363e1bbf1bbe7593c6fb9aa4 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 15:01:37 +0100 Subject: ci: initialise quality-checks job --- .github/workflows/deploy.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/deploy.yml (limited to '.github/workflows') diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b214678 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,33 @@ +name: de-project-bentley + +on: + push: + branches: [development, staging] + pull_request: + branches: [main, development, staging] + +jobs: + quality-checks: + runs-on: ubuntu-latest + steps: + - uses : actions/checkout@v2 + - name : Setup + uses : actions/setup-python@v2 + with: + python-version: 3.11 + - name : Dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pylint black bandit safety + - name : Linting + run: | + flake8 . + pylint **/*.py + - name : Formatting + run: | + black --check . + - name: Security + run: | + bandit -r . + safety check + \ No newline at end of file -- cgit v1.2.3 From 8bbf8803473badc357a9747a5ccff32c8aea4dc8 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 15:33:58 +0100 Subject: fix(ci): replace glob pattern for pylint --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b214678..71b2871 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: - name : Linting run: | flake8 . - pylint **/*.py + find . -name "*.py" | xargs pylint - name : Formatting run: | black --check . -- cgit v1.2.3 From 43cc61cd535609b59948ba75d8d9ea859bf8d990 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 15:59:08 +0100 Subject: ci: add terraform quality checks --- .github/workflows/terraform.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/terraform.yml (limited to '.github/workflows') diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 0000000..d28a357 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,34 @@ +name: terraform-quality-checks + +on: + push: + branches: [development] + paths: + - 'terraform/**.tf' + - 'terraform/**.tfvars' + pull_request: + branches: [development, staging] + paths: + - 'terraform/**.tf' + - 'terraform/**.tfvars' +jobs: + terraform-validation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: latest # Using the latest version, but not sure if it's the best practice + - name: Format + run: terraform fmt -check -recursive + - name: Init + run: terraform init -backend=false + - name: Validate + run: terraform validate + - name: Setup TFLint + uses: terraform-linters/setup-tflint@v2 + with: + tflint_version: latest + - name: Run TFLint + run: tflint -f compact \ No newline at end of file -- cgit v1.2.3 From 4eef583c0ad16f938bcec1eaaf83ace974b8c667 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 15:59:34 +0100 Subject: ci: add python quality checks (separately) --- .github/workflows/python.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/python.yml (limited to '.github/workflows') diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..4f752b7 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,33 @@ +name: python-quality-checks + +on: + push: + branches: [development] + pull_request: + branches: [development, staging] + +jobs: + quality-checks: + runs-on: ubuntu-latest + steps: + - uses : actions/checkout@v2 + - name : Setup + uses : actions/setup-python@v2 + with: + python-version: 3.11 + - name : Dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pylint black bandit safety + - name : Linting + run: | + flake8 . + find . -name "*.py" | xargs pylint + - name : Formatting + run: | + black --check . + - name: Security + run: | + bandit -r . + safety check + \ No newline at end of file -- cgit v1.2.3 From 20c7b0c647b455958bca02b263fb50e330fe6775 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 16:00:07 +0100 Subject: ci: rm unused deploy.yml --- .github/workflows/deploy.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/deploy.yml (limited to '.github/workflows') diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 71b2871..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: de-project-bentley - -on: - push: - branches: [development, staging] - pull_request: - branches: [main, development, staging] - -jobs: - quality-checks: - runs-on: ubuntu-latest - steps: - - uses : actions/checkout@v2 - - name : Setup - uses : actions/setup-python@v2 - with: - python-version: 3.11 - - name : Dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pylint black bandit safety - - name : Linting - run: | - flake8 . - find . -name "*.py" | xargs pylint - - name : Formatting - run: | - black --check . - - name: Security - run: | - bandit -r . - safety check - \ No newline at end of file -- cgit v1.2.3 From c849807a008f738b0e3b9230521b4112ae8a71b8 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 16:01:39 +0100 Subject: ci: set cwd to ./terraform.yml --- .github/workflows/terraform.yml | 3 +++ 1 file changed, 3 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index d28a357..c349756 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -14,6 +14,9 @@ on: jobs: terraform-validation: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./terraform steps: - uses: actions/checkout@v2 - name: Setup Terraform -- cgit v1.2.3 From 6f5759ceccb7f84cbd7898a057504f49a0cbb790 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Tue, 13 Aug 2024 16:05:20 +0100 Subject: ci: check if python files exist --- .github/workflows/python.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 4f752b7..7d5b5b1 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -7,7 +7,24 @@ on: branches: [development, staging] jobs: + + check-if-py-files-exist: + runs-on: ubuntu-latest + outputs: + py_files_exist: ${{ steps.check.outputs.py_files_exist }} + steps: + - uses: actions/checkout@v2 + - id: check_files + run: | + if [ -n "$(find . -name '*.py')" ]; then + echo "::set-output name=py_files_exist::true" + else + echo "::set-output name=py_files_exist::false" + fi + quality-checks: + needs: check-if-py-files-exist + if: ${{ needs.check-if-py-files-exist.outputs.py_files_exist == 'true' }} runs-on: ubuntu-latest steps: - uses : actions/checkout@v2 -- cgit v1.2.3