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

Hide outdated comments #345

Merged
merged 6 commits into from
Aug 2, 2024
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
28 changes: 14 additions & 14 deletions .github/workflows/test-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,20 +863,20 @@ jobs:
path: tests/workflows/test-plan/plan
label: test-plan test_plan_1_4

arm64:
runs-on: buildjet-2vcpu-ubuntu-2204-arm
name: Test on arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Plan
uses: ./terraform-plan
with:
path: tests/workflows/test-plan/plan
label: arm64
# arm64:
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
# name: Test on arm64
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Plan
# uses: ./terraform-plan
# with:
# path: tests/workflows/test-plan/plan
# label: arm64

always_new:
runs-on: ubuntu-latest
Expand Down
104 changes: 54 additions & 50 deletions .github/workflows/test-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ jobs:

- name: Check the version
run: |
if [[ "${{ steps.terraform-version.outputs.terraform }}" != *"1.8"* ]]; then
if [[ "${{ steps.terraform-version.outputs.terraform }}" != *"1.9"* ]]; then
echo "::error:: Latest version was not used"
exit 1
fi
Expand Down Expand Up @@ -627,55 +627,55 @@ jobs:
exit 1
fi

arm64:
runs-on: buildjet-2vcpu-ubuntu-2204-arm
name: Version detection on arm
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Version unsupported on arm
uses: ./terraform-version
continue-on-error: true
id: arm-unsupported
env:
TERRAFORM_VERSION: 0.12.0
with:
path: tests/workflows/test-version/empty

- name: Check failed to download unsupported platform
run: |
if [[ "${{ steps.arm-unsupported.outcome }}" != "failure" ]]; then
echo "Did not fail correctly"
exit 1
fi

- name: Version doesn't exist
uses: ./terraform-version
continue-on-error: true
id: no-such-version
with:
path: tests/workflows/test-version/nosuchversion

- name: Check failed to download no such version
run: |
if [[ "${{ steps.no-such-version.outcome }}" != "failure" ]]; then
echo "Did not fail correctly"
exit 1
fi

- name: Test terraform-version
uses: ./terraform-version
id: terraform-version
with:
path: tests/workflows/test-version/tfswitch

- name: Check the version
run: |
if [[ "${{ steps.terraform-version.outputs.terraform }}" != "1.1.0" ]]; then
echo "::error:: Terraform version not set from .tfswitchrc"
exit 1
fi
# arm64:
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
# name: Version detection on arm
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Version unsupported on arm
# uses: ./terraform-version
# continue-on-error: true
# id: arm-unsupported
# env:
# TERRAFORM_VERSION: 0.12.0
# with:
# path: tests/workflows/test-version/empty
#
# - name: Check failed to download unsupported platform
# run: |
# if [[ "${{ steps.arm-unsupported.outcome }}" != "failure" ]]; then
# echo "Did not fail correctly"
# exit 1
# fi
#
# - name: Version doesn't exist
# uses: ./terraform-version
# continue-on-error: true
# id: no-such-version
# with:
# path: tests/workflows/test-version/nosuchversion
#
# - name: Check failed to download no such version
# run: |
# if [[ "${{ steps.no-such-version.outcome }}" != "failure" ]]; then
# echo "Did not fail correctly"
# exit 1
# fi
#
# - name: Test terraform-version
# uses: ./terraform-version
# id: terraform-version
# with:
# path: tests/workflows/test-version/tfswitch
#
# - name: Check the version
# run: |
# if [[ "${{ steps.terraform-version.outputs.terraform }}" != "1.1.0" ]]; then
# echo "::error:: Terraform version not set from .tfswitchrc"
# exit 1
# fi

terraform_opentofu_version:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -740,6 +740,8 @@ jobs:
opentofu_version_pre_release_nosig:
runs-on: ubuntu-latest
name: OPENTOFU_VERSION pre-release with tofu action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -770,6 +772,8 @@ jobs:
opentofu_old_version:
runs-on: ubuntu-latest
name: Prefer OpenTofu, but only Terraform matches constraints
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
47 changes: 24 additions & 23 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,30 @@ jobs:
run: |
GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests

pytest_arm64:
runs-on: buildjet-2vcpu-ubuntu-2204-arm
name: pytest arm64
needs: pytest_amd64
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt

gpg --recv-keys C874011F0AB405110D02105534365D9472D7468F \
&& echo "C874011F0AB405110D02105534365D9472D7468F:6:" | gpg --import-ownertrust

- name: Run tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TERRAFORM_ACTIONS_GITHUB_TOKEN: No
run: |
GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests
# buildjet doesn't start the job most of the time
# pytest_arm64:
# runs-on: buildjet-2vcpu-ubuntu-2204-arm
# name: pytest arm64
# needs: pytest_amd64
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r tests/requirements.txt
#
# gpg --recv-keys C874011F0AB405110D02105534365D9472D7468F \
# && echo "C874011F0AB405110D02105534365D9472D7468F:6:" | gpg --import-ownertrust
#
# - name: Run tests
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# TERRAFORM_ACTIONS_GITHUB_TOKEN: No
# run: |
# GNUPGHOME=$HOME/.gnupg PYTHONPATH=image/tools:image/src pytest tests

tofu:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions image/src/github_actions/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
IssueUrl = NewType('IssueUrl', GitHubUrl)
CommentUrl = NewType('CommentUrl', GitHubUrl)
CommentReactionUrl = NewType('CommentReactionUrl', GitHubUrl)
NodeId = NewType('NodeId', str)


class GithubApi:
Expand Down
8 changes: 7 additions & 1 deletion image/src/github_pr_comment/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from github_pr_comment.backend_config import complete_config, partial_config
from github_pr_comment.backend_fingerprint import fingerprint
from github_pr_comment.cmp import plan_cmp, remove_warnings, remove_unchanged_attributes
from github_pr_comment.comment import find_comment, TerraformComment, update_comment, serialize, deserialize
from github_pr_comment.comment import find_comment, TerraformComment, update_comment, serialize, deserialize, hide_comment
from github_pr_comment.hash import comment_hash, plan_hash, plan_out_hash
from github_pr_comment.plan_formatting import format_diff
from plan_renderer.outputs import render_outputs
Expand Down Expand Up @@ -323,6 +323,7 @@ def new_pr_comment(backend_fingerprint: bytes) -> TerraformComment:
return TerraformComment(
issue_url=issue_url,
comment_url=None,
node_id=None,
headers={k: v for k, v in headers.items() if v is not None},
description='',
summary='',
Expand Down Expand Up @@ -497,6 +498,11 @@ def main() -> int:
headers=comment.headers | {'closed': True},
status=':spider_web: Plan is outdated'
)
hide_comment(
github,
comment,
'OUTDATED'
)

# Create the replacement comment
comment = new_pr_comment(backend_fingerprint)
Expand Down
Loading
Loading