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

merge upstream (#28) #39

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"evendead.help-me-add",
"charliermarsh.ruff",
"streetsidesoftware.code-spell-checker",
"njqdev.vscode-python-typehint"
"njqdev.vscode-python-typehint",
"Cameron.vscode-pytest"
]
}
}
Expand Down
118 changes: 56 additions & 62 deletions .github/workflows/action_integration_test.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,56 @@
name: "GitHub Action integration test"

permissions:
contents: write
pull-requests: write

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
integration-test:
env:
report_json_file: InfraPatch_Statistics.json

name: "Run GitHub Action integration test"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run in report only mode
uses: ./
with:
report_only: true

- name: Run in update mode
id: update
uses: ./
with:
report_only: false
target_branch_name: "feat/infrapatch_test_${{ github.run_number }}"

- name: Check update result
shell: pwsh
run: |
$report = Get-Content $env:report_json_file -Raw | ConvertFrom-Json
if ( -not $report.total_resources -gt 0 ) {
throw "Failed to get resources"
}
if ( -not ( $report.resources_patched -gt 3 ) ) {
throw "No resources should be patched"
}
if ( $report.errors -gt 0 ) {
throw "Errors have been detected"
}

- name: Delete created branch$
if: always()
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{github.token}}
branches: ${{ steps.update.outputs.target_branch }}
soft_fail: true






name: "GitHub Action integration test"

on:
workflow_call:

jobs:
integration-test:
env:
report_json_file: InfraPatch_Statistics.json

name: "Run GitHub Action integration test"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run in report only mode
uses: ./
with:
report_only: true

- name: Run in update mode
id: update
uses: ./
with:
report_only: false
target_branch_name: "feat/infrapatch_test_${{ github.run_number }}"

- name: Check update result
shell: pwsh
run: |
$report = Get-Content $env:report_json_file -Raw | ConvertFrom-Json
if ( -not $report.total_resources -gt 0 ) {
throw "Failed to get resources"
}
if ( -not ( $report.resources_patched -gt 3 ) ) {
throw "No resources should be patched"
}
if ( $report.errors -gt 0 ) {
throw "Errors have been detected"
}

- name: Delete created branch$
if: always()
uses: dawidd6/action-delete-branch@v3
with:
branches: ${{ steps.update.outputs.target_branch }}
soft_fail: true
env:
GITHUB_TOKEN: ${{github.token}}






28 changes: 18 additions & 10 deletions .github/workflows/check_format_and_lint.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
name: "Check Format and Lint Code"

on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
branches:
- main
workflow_call:

jobs:
check_code:
name: "Check Format and Lint Code"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get Python Version
id: get_python_verion
run: |
python_version=$(cat python_version.txt)
echo "Using Python version $python_version"
echo "::set-output name=python_version::$(echo $python_version)"

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.11
python-version: ${{ steps.get_python_verion.outputs.python_version }}

- name: Install Dependencies
run: |
Expand All @@ -31,4 +34,9 @@ jobs:

- name: Check code with ruff
run: ruff check .







Original file line number Diff line number Diff line change
@@ -1,78 +1,79 @@
name: CLI Integration test

on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
branches:
- main

jobs:
test:
# only run if not closed or closed with merge
if: ${{ github.event.pull_request.merged == true || github.event.pull_request.state != 'closed' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report_json_file: InfraPatch_Statistics.json

strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest Windows does currently not work because of pygohcl
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install InfraPatch CLI
run: |
python -m pip install .
shell: bash

- name: Run InfraPatch report
shell: bash
run: infrapatch --debug report --dump-json-statistics

- name: Check report result
shell: pwsh
run: |
$report = Get-Content $env:report_json_file -Raw | ConvertFrom-Json
if ( -not $report.total_resources -gt 0 ) {
throw "Failed to get resources"
}
if ( $report.resources_patched -ne 0 ) {
throw "No resources should be patched"
}
if ( $report.errors -gt 0 ) {
throw "Errors have been detected"
}

- name: Run InfraPatch update
shell: bash
run: infrapatch --debug update --dump-json-statistics --confirm

- name: Check update result
shell: pwsh
run: |
$report = Get-Content $env:report_json_file -Raw | ConvertFrom-Json
if ( -not $report.total_resources -gt 0 ) {
throw "Failed to get resources"
}
if ( -not ( $report.resources_patched -gt 3 ) ) {
throw "No resources should be patched"
}
if ( $report.errors -gt 0 ) {
throw "Errors have been detected"
}


name: CLI Integration test

on:
workflow_call:

jobs:
cli_integration_test:
name: CLI Integration test
# only run if not closed or closed with merge
if: ${{ github.event.pull_request.merged == true || github.event.pull_request.state != 'closed' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report_json_file: InfraPatch_Statistics.json

strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest Windows does currently not work because of pygohcl
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Python Version
id: get_python_verion
run: |
python_version=$(cat python_version.txt)
echo "Using Python version $python_version"
echo "::set-output name=python_version::$(echo $python_version)"

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ steps.get_python_verion.outputs.python_version }}

- name: Install InfraPatch CLI
run: |
python -m pip install .
shell: bash

- name: Run InfraPatch report
shell: bash
run: infrapatch --debug report --dump-json-statistics

- name: Check report result
shell: pwsh
run: |
$report = Get-Content $env:report_json_file -Raw | ConvertFrom-Json
if ( -not $report.total_resources -gt 0 ) {
throw "Failed to get resources"
}
if ( $report.resources_patched -ne 0 ) {
throw "No resources should be patched"
}
if ( $report.errors -gt 0 ) {
throw "Errors have been detected"
}

- name: Run InfraPatch update
shell: bash
run: infrapatch --debug update --dump-json-statistics --confirm

- name: Check update result
shell: pwsh
run: |
$report = Get-Content $env:report_json_file -Raw | ConvertFrom-Json
if ( -not $report.total_resources -gt 0 ) {
throw "Failed to get resources"
}
if ( -not ( $report.resources_patched -gt 3 ) ) {
throw "At least 3 resources should be patched"
}
if ( $report.errors -gt 0 ) {
throw "Errors have been detected"
}


35 changes: 35 additions & 0 deletions .github/workflows/composition.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: InfraPatch Checks

permissions:
contents: write
pull-requests: write

on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:

check_code:
uses: ./.github/workflows/check_format_and_lint.yml

unit_tests:
needs: check_code
uses: ./.github/workflows/unit_tests.yml

cli_integration_test:
needs: unit_tests
uses: ./.github/workflows/cli_integration_test.yml

github_action_integration_test:
needs: unit_tests
uses: ./.github/workflows/action_integration_test.yml

Loading
Loading