Skip to content

Commit

Permalink
Merge branch 'main' into CXF-100797-Service-Token-Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
srushti-patl authored Oct 31, 2024
2 parents a07c062 + fe0d4f8 commit 1fa9dac
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 26 deletions.
65 changes: 64 additions & 1 deletion .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:
pull-requests: write

jobs:
main:
check-pr-title:
name: Validate PR title
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -43,3 +43,66 @@ jobs:
with:
header: pr-title-lint-error
delete: true

enforce-packages:
name: Prevent new files in `equinix` package
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
id: check_added_files
with:
result-encoding: string
retries: 3
script: |
const files = await github.paginate(github.rest.pulls.listFiles,{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})
const blockedFiles = []
for (const file of files) {
if (file.status === "added" && file.filename.match(/equinix\/[^\/]*\.go/)) {
blockedFiles.push("- " + file.filename)
}
}
var errorMessage = ""
if (blockedFiles.length > 0) {
errorMessage = `The following files were added to the \`equinix\` package and must be moved somewhere else:
${blockedFiles.join("\n")}
`
core.setFailed(errorMessage)
}
return errorMessage
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.check_added_files.outputs.result != '')
with:
header: files-added-to-equinix-error
message: |
We are actively working to reduce the amount of code in the `equinix`
package to avoid unintentional code sharing.
New files should be added in an isolated package instead of adding
more code to the `equinix` package. You may need to refactor and/or
temporarily duplicate existing code in order to move your new code
to an isolated package.
Details:
```
${{ steps.check_added_files.outputs.result }}
```
# Delete a previous comment when the issue has been resolved
- if: steps.check_added_files.outputs.result == ''
uses: marocchino/sticky-pull-request-comment@v2
with:
header: files-added-to-equinix-error
delete: true
25 changes: 0 additions & 25 deletions equinix/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,6 @@ func TestProvider_isEmpty(t *testing.T) {
}
}

func TestProvider_setSchemaValueIfNotEmpty(t *testing.T) {
// given
key := "test"
s := map[string]*schema.Schema{
key: {
Type: schema.TypeString,
Optional: true,
},
}
var b *int = nil
d := schema.TestResourceDataRaw(t, s, make(map[string]interface{}))
// when
setSchemaValueIfNotEmpty(key, b, d)
// then
_, ok := d.GetOk(key)
assert.False(t, ok, "Key was not set")
}

// Deprecated test moved to internal/comparissons/comparisons_test.go
func TestProvider_slicesMatch(t *testing.T) {
// given
Expand Down Expand Up @@ -250,10 +232,3 @@ func copyMap(source map[string]interface{}) map[string]interface{} {
}
return target
}

func setSchemaValueIfNotEmpty(key string, value interface{}, d *schema.ResourceData) error {
if !isEmpty(value) {
return d.Set(key, value)
}
return nil
}

0 comments on commit 1fa9dac

Please sign in to comment.