Skip to content

Commit

Permalink
Lint codebase, fix CI (#205)
Browse files Browse the repository at this point in the history
* Fix CI

* Lint codebase

* Fix deprecations

* *

* Fix test

* Revert panic
  • Loading branch information
ofalvai authored Jul 23, 2024
1 parent 45842c8 commit a8287bd
Show file tree
Hide file tree
Showing 15 changed files with 456 additions and 513 deletions.
82 changes: 41 additions & 41 deletions .github/workflows/stale-issues-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,53 @@ on:
# Allows manually running
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#manual-events
workflow_dispatch:

schedule:
# Runs at 08:00 UTC every day
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
- cron: '0 8 * * *'
# Runs at 08:00 UTC every day
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
- cron: 0 8 * * *

jobs:
stale:
runs-on: ubuntu-latest
steps:
# https://github.com/actions/stale
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.CORESTEPS_BOT_GITHUB_TOKEN }}
# do not manage PRs
days-before-pr-stale: -1
days-before-pr-close: -1
# stale issue config
exempt-issue-labels: 'bug'
days-before-issue-stale: 90
days-before-issue-close: 21
stale-issue-message: |
Hello there, I'm a bot. On behalf of the community I thank you for opening this issue.
# https://github.com/actions/stale
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.CORESTEPS_BOT_GITHUB_TOKEN }}
# do not manage PRs
days-before-pr-stale: -1
days-before-pr-close: -1
# stale issue config
exempt-issue-labels: bug
days-before-issue-stale: 90
days-before-issue-close: 21
stale-issue-message: |
Hello there, I'm a bot. On behalf of the community I thank you for opening this issue.
To help our human contributors focus on the most relevant reports, I check up on old issues to see if they're still relevant.
This issue has had no activity for 90 days, so I marked it as stale.
To help our human contributors focus on the most relevant reports, I check up on old issues to see if they're still relevant.
This issue has had no activity for 90 days, so I marked it as stale.
The community would appreciate if you could check if the issue still persists. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me".
The community would appreciate if you could check if the issue still persists. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me".
If no comment left within 21 days, this issue will be closed.
close-issue-message: >
I'll close this issue as it doesn't seem to be relevant anymore.
If no comment left within 21 days, this issue will be closed.
close-issue-message: >
I'll close this issue as it doesn't seem to be relevant anymore.
We believe an old issue probably has a bunch of context that's no longer relevant, therefore, if the problem still persists, please open a new issue.
stale-issue-label: stale
# https://github.com/jakejarvis/wait-action
# Wait 1m to make sure lock-threads will actually lock the issue where stale just recently left a message.
- uses: jakejarvis/wait-action@master
with:
time: '1m'
# https://github.com/dessant/lock-threads
- uses: dessant/lock-threads@v2
with:
github-token: ${{ secrets.CORESTEPS_BOT_GITHUB_TOKEN }}
# do not manage PRs
process-only: issues
# stale issue config
issue-lock-inactive-days: 0 # immediately lock closed issues
issue-lock-reason: ''
We believe an old issue probably has a bunch of context that's no longer relevant, therefore, if the problem still persists, please open a new issue.
stale-issue-label: stale
# https://github.com/jakejarvis/wait-action
# Wait 1m to make sure lock-threads will actually lock the issue where stale just recently left a message.
- uses: jakejarvis/wait-action@master
with:
time: 1m
# https://github.com/dessant/lock-threads
- uses: dessant/lock-threads@v2
with:
github-token: ${{ secrets.CORESTEPS_BOT_GITHUB_TOKEN }}
# do not manage PRs
process-only: issues
# stale issue config
issue-lock-inactive-days: 0 # immediately lock closed issues
issue-lock-reason: ""
2 changes: 1 addition & 1 deletion androidartifact/apk_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func parseAPKInfo(apkPath string) (ApkInfo, error) {
VersionCode: manifest.VersionCode,
VersionName: manifest.VersionName,
MinSDKVersion: manifest.UsesSdk.MinSDKVersion,
RawPackageContent: string(manifestContent.Bytes()),
RawPackageContent: manifestContent.String(),
}, nil
}

Expand Down
3 changes: 0 additions & 3 deletions androidartifact/file_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ func mapBuildArtifacts(pths []string) ArtifactMap {
}

if len(info.SplitInfo.SplitParams) == 0 {
if len(artifact.APK) != 0 {
// might -unsigned and -bitrise-signed versions both exist of the same apk
}
artifact.APK = pth
buildTypeArtifacts[info.ProductFlavour] = artifact
moduleArtifacts[info.BuildType] = buildTypeArtifacts
Expand Down
37 changes: 0 additions & 37 deletions androidartifact/file_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/bitrise-io/go-utils/pretty"
"github.com/bitrise-io/go-utils/sliceutil"
)

func TestParseArtifactPath(t *testing.T) {
Expand Down Expand Up @@ -269,38 +268,6 @@ func Test_mapBuildArtifacts(t *testing.T) {
}
}

func comparseSlice(a, b []string) bool {
if len(a) != len(b) {
return false
}

for _, e := range a {
if !sliceutil.IsStringInSlice(e, b) {
return false
}
}
return true
}

func compareMapStringStringSlice(a, b map[string][]string) bool {
if len(a) != len(b) {
return false
}

for keyA, valueA := range a {
valueB, ok := b[keyA]
if !ok {
return false
}

if !comparseSlice(valueA, valueB) {
return false
}
}

return true
}

func TestCreateSplitArtifactMeta(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -426,10 +393,6 @@ func TestCreateSplitArtifactMeta(t *testing.T) {
}

func TestFindSameArtifact(t *testing.T) {
type args struct {
pth string
pths []string
}
tests := []struct {
name string
pth string
Expand Down
155 changes: 74 additions & 81 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ app:
workflows:
test:
steps:
- go-list:
inputs:
- exclude: |-
*/vendor/*
*/mocks
- golint: {}
- errcheck: {}
- go-test: {}
- git::https://github.com/bitrise-steplib/steps-check.git: { }

ci:
before_run:
Expand Down Expand Up @@ -141,7 +134,7 @@ workflows:
- debug_mode: "true"
- path::./:
title: Android Test compressed with custom name from file path
run_if: true
run_if: "true"
inputs:
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
Expand All @@ -155,14 +148,14 @@ workflows:
- script:
is_always_run: true
inputs:
- content: |-
#!/bin/bash
set -ex
# Force turn on the parallel uploads
envman add --key BITRISE_DEPLOY_UPLOAD_CONCURRENCY --value "10"
- content: |-
#!/bin/bash
set -ex
# Force turn on the parallel uploads
envman add --key BITRISE_DEPLOY_UPLOAD_CONCURRENCY --value "10"
- path::./:
title: Many xml resources test
run_if: true
run_if: "true"
inputs:
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
Expand All @@ -175,35 +168,35 @@ workflows:
- set-env-var:
is_always_run: true
inputs:
- destination_keys: PIPELINE_FILE_3
- value: "./xcresults/xcresult3-flaky-with-rerun.xcresult"
- destination_keys: PIPELINE_FILE_3
- value: ./xcresults/xcresult3-flaky-with-rerun.xcresult
- path::./:
title: Pipeline intermediate file upload
run_if: true
run_if: "true"
inputs:
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
- is_compress: "false"
- deploy_path: ./ipas/ios-simple-objc.ipa
- pipeline_intermediate_files: |-
./ipas/ios-simple-objc.ipa:PIPELINE_FILE_1
./xcresults/xcresult3-flaky-with-rerun.xcresult:PIPELINE_FILE_2
PIPELINE_FILE_3
- notify_user_groups: $NOTIFY_USER_GROUPS
- notify_email_list: $NOTIFY_EMAIL_LIST
- is_enable_public_page: "true"
- debug_mode: "true"
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
- is_compress: "false"
- deploy_path: ./ipas/ios-simple-objc.ipa
- pipeline_intermediate_files: |-
./ipas/ios-simple-objc.ipa:PIPELINE_FILE_1
./xcresults/xcresult3-flaky-with-rerun.xcresult:PIPELINE_FILE_2
PIPELINE_FILE_3
- notify_user_groups: $NOTIFY_USER_GROUPS
- notify_email_list: $NOTIFY_EMAIL_LIST
- is_enable_public_page: "true"
- debug_mode: "true"
- path::./:
title: Deploy path points to invalid path
title: Deploy path points to invalid path
inputs:
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
- is_compress: "false"
- deploy_path: /tmp/nonexistent
- notify_user_groups: $NOTIFY_USER_GROUPS
- notify_email_list: $NOTIFY_EMAIL_LIST
- is_enable_public_page: "true"
- debug_mode: "true"
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
- is_compress: "false"
- deploy_path: /tmp/nonexistent
- notify_user_groups: $NOTIFY_USER_GROUPS
- notify_email_list: $NOTIFY_EMAIL_LIST
- is_enable_public_page: "true"
- debug_mode: "true"
- script:
title: Output (generated by the Step) tests
inputs:
Expand Down Expand Up @@ -272,51 +265,51 @@ workflows:

_file_redaction:
steps:
- script:
is_always_run: true
inputs:
- content: |-
#!/bin/bash
set -ex
# Create empty temporary file
temp_file_path=$(mktemp)
# Add some content
echo "this is not a secret\nthis is a secret\nagain not a secret\n" > $temp_file_path
# Export the file and the secret as env vars
envman add --key FILE_TO_REDACT --value "${temp_file_path}"
envman add --key SUPER_SECRET --value "this is a secret" --sensitive
- path::./:
title: File redaction test
run_if: true
inputs:
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
- deploy_path: ""
- files_to_redact: $FILE_TO_REDACT
- debug_mode: "true"
- script:
is_always_run: true
inputs:
- content: |-
#!/bin/bash
set -ex
actual_content=$(<$FILE_TO_REDACT)
expected_content="this is not a secret\n[REDACTED]\nagain not a secret\n"
# Fail if the content of the redacted file does not meat our expected value
if [[ "$actual_content" != "$expected_content" ]]; then
echo "$FILE_TO_REDACT was not redacted"
echo "Actual content: "$actual_content""
echo "Expected content: "$expected_content""
exit 1
fi
- script:
is_always_run: true
inputs:
- content: |-
#!/bin/bash
set -ex
# Create empty temporary file
temp_file_path=$(mktemp)
# Add some content
echo "this is not a secret\nthis is a secret\nagain not a secret\n" > $temp_file_path
# Export the file and the secret as env vars
envman add --key FILE_TO_REDACT --value "${temp_file_path}"
envman add --key SUPER_SECRET --value "this is a secret" --sensitive
- path::./:
title: File redaction test
run_if: "true"
inputs:
- build_url: $BITRISE_BUILD_URL
- build_api_token: $BITRISE_BUILD_API_TOKEN
- deploy_path: ""
- files_to_redact: $FILE_TO_REDACT
- debug_mode: "true"
- script:
is_always_run: true
inputs:
- content: |-
#!/bin/bash
set -ex
actual_content=$(<$FILE_TO_REDACT)
expected_content="this is not a secret\n[REDACTED]\nagain not a secret\n"
# Fail if the content of the redacted file does not meat our expected value
if [[ "$actual_content" != "$expected_content" ]]; then
echo "$FILE_TO_REDACT was not redacted"
echo "Actual content: "$actual_content""
echo "Expected content: "$expected_content""
exit 1
fi
generate_readme:
steps:
- git::https://github.com/bitrise-steplib/steps-readme-generator.git@main:
inputs:
- example_section: docs/examples.md
- git::https://github.com/bitrise-steplib/steps-readme-generator.git@main:
inputs:
- example_section: docs/examples.md

audit-this-step:
steps:
Expand Down
2 changes: 0 additions & 2 deletions fileredactor/fileredactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/bitrise-io/go-utils/v2/redactwriter"
)

const bufferSize = 64 * 1024

// FileRedactor is an interface for a structure which, given a slice of file paths and another slice of secrets can
// process the specified files to redact secrets from them.
type FileRedactor interface {
Expand Down
4 changes: 2 additions & 2 deletions report/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestCreateReport(t *testing.T) {

response, err := apiClient.CreateReport(tt.params)
assert.Equal(t, fmt.Sprintf("%s/html_reports.json", buildURL), request.URL.String())
assert.Equal(t, []string{authToken}, request.Header["BUILD_API_TOKEN"])
assert.Equal(t, []string{authToken}, request.Header["BUILD_API_TOKEN"]) //nolint:staticcheck // See TestReportClient.perform()

if tt.wantError {
assert.Equal(t, tt.expectedError, err)
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestFinishReport(t *testing.T) {

err := apiClient.FinishReport(tt.identifier, tt.allAssetsUploaded)
assert.Equal(t, fmt.Sprintf("%s/html_reports/%s.json", buildURL, tt.identifier), request.URL.String())
assert.Equal(t, []string{authToken}, request.Header["BUILD_API_TOKEN"])
assert.Equal(t, []string{authToken}, request.Header["BUILD_API_TOKEN"]) //nolint:staticcheck // See TestReportClient.perform()

if tt.wantError {
assert.Equal(t, tt.expectedError, err)
Expand Down
Loading

0 comments on commit a8287bd

Please sign in to comment.