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

feat: adds test infrastructure to run acceptance tests on PRs #1553

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

marcosuma
Copy link
Collaborator

Description

Link to any related issue(s): https://jira.mongodb.org/browse/INTMDB-1034

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

@marcosuma marcosuma marked this pull request as ready for review October 24, 2023 12:51
@marcosuma marcosuma requested a review from a team as a code owner October 24, 2023 12:51
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || inputs.parent-event-name == 'release' }}
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
assume_role:
- 'mongodbatlas/**provider**.go'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems very broad and it's also matched e.g. in config, what list of files do we want to match here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of making it broad because I'd thought it should run for all PR changes since it's an authentication type of test. Happy to change here later if we see it's not worth it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case we may want to have it in the general "config" group instead of a separated asssume-role group.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's see how it goes, I'll keep this comment into account to improve things. Let us just see how it works.

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/framework/validator 68%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util 17%
Summary 3% (272 / 10318)

@marcosuma marcosuma merged commit 5156bea into INTMDB-1034-add-test Oct 26, 2023
21 checks passed
@marcosuma marcosuma deleted the INTMDB-1034-add-workflow branch October 26, 2023 09:26
marcosuma added a commit that referenced this pull request Oct 26, 2023
* adds test coverage.

* pre-check that regular credentials env variables are not set.

* feat: adds test infrastructure to run acceptance tests on PRs (#1553)

* adds test infra.

* fix.
marcosuma added a commit that referenced this pull request Oct 26, 2023
…with an AWS Role (#1551)

* set all possible default values taken from environment varialbes (if exist).

* addresses comments.

* feat: adds test coverage for AWS Role Authentication (#1552)

* adds test coverage.

* pre-check that regular credentials env variables are not set.

* feat: adds test infrastructure to run acceptance tests on PRs (#1553)

* adds test infra.

* fix.

* Update mongodbatlas/provider.go

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>

* Update mongodbatlas/provider.go

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>

* addresses comments.

---------

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>
marcosuma added a commit that referenced this pull request Oct 30, 2023
* fixed region value when creating configuration for aws role authentication.

* restore go.mod and go.sum.

* separates logic into util func.

* feat: adds more environment variables to be used when authenticating with an AWS Role (#1551)

* set all possible default values taken from environment varialbes (if exist).

* addresses comments.

* feat: adds test coverage for AWS Role Authentication (#1552)

* adds test coverage.

* pre-check that regular credentials env variables are not set.

* feat: adds test infrastructure to run acceptance tests on PRs (#1553)

* adds test infra.

* fix.

* Update mongodbatlas/provider.go

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>

* Update mongodbatlas/provider.go

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>

* addresses comments.

---------

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>

---------

Co-authored-by: Leo Antoli <430982+lantoli@users.noreply.github.com>
Comment on lines +453 to +481
assume_role:
needs: [ change-detection, fetch-sts-assume-role-creds]
if: ${{ needs.change-detection.outputs.config == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event.label.name == 'run-testacc' || github.event.label.name == 'run-testacc-config' || inputs.parent-event-name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Acceptance Tests
env:
ASSUME_ROLE_ARN: ${{ vars.ASSUME_ROLE_ARN }}
AWS_REGION: ${{ vars.AWS_REGION }}
STS_ENDPOINT: ${{ vars.STS_ENDPOINT }}
SECRET_NAME: ${{ vars.AWS_SECRET_NAME }}
AWS_ACCESS_KEY_ID: ${{ needs.fetch-sts-assume-role-creds.outputs.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ needs.fetch-sts-assume-role-creds.outputs.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ needs.fetch-sts-assume-role-creds.outputs.AWS_SESSION_TOKEN }}
MONGODB_ATLAS_ORG_ID: ${{ vars.MONGODB_ATLAS_ORG_ID_CLOUD_DEV }}
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}
TF_LOG: ${{ vars.LOG_LEVEL }}
TF_ACC: 1
PARALLEL_GO_TEST: 20
CI: true
TEST_REGEX: "^TestAccSTSAssumeRole"
run: make testacc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcosuma This change is leaking our AWS credentials:

https://github.com/mongodb/terraform-provider-mongodbatlas/actions/runs/6728120776/job/18286966224#step:4:10. Please revert this change and recreate our AWS keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants