diff --git a/.github/workflows/stale-issues-workflow.yml b/.github/workflows/stale-issues-workflow.yml index bef5e784..78df5d40 100644 --- a/.github/workflows/stale-issues-workflow.yml +++ b/.github/workflows/stale-issues-workflow.yml @@ -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: "" diff --git a/androidartifact/apk_info.go b/androidartifact/apk_info.go index fb3e3b8f..d9cda11b 100644 --- a/androidartifact/apk_info.go +++ b/androidartifact/apk_info.go @@ -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 } diff --git a/androidartifact/file_name.go b/androidartifact/file_name.go index fed58d40..d6e5f0aa 100644 --- a/androidartifact/file_name.go +++ b/androidartifact/file_name.go @@ -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 diff --git a/androidartifact/file_name_test.go b/androidartifact/file_name_test.go index a055f1b3..8abcc12f 100644 --- a/androidartifact/file_name_test.go +++ b/androidartifact/file_name_test.go @@ -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) { @@ -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 @@ -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 diff --git a/bitrise.yml b/bitrise.yml index 0c2a238d..cf34fae9 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -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: @@ -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 @@ -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 @@ -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: @@ -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: diff --git a/fileredactor/fileredactor.go b/fileredactor/fileredactor.go index b932d2cb..c4d8f048 100644 --- a/fileredactor/fileredactor.go +++ b/fileredactor/fileredactor.go @@ -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 { diff --git a/report/api/api_test.go b/report/api/api_test.go index 16ea4ef0..d3bceefb 100644 --- a/report/api/api_test.go +++ b/report/api/api_test.go @@ -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) @@ -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) diff --git a/report/collect.go b/report/collect.go index 282470e3..d0348925 100644 --- a/report/collect.go +++ b/report/collect.go @@ -95,9 +95,7 @@ func detectContentType(path string) string { return fallbackType } defer func() { - if err := file.Close(); err != nil { - // This is empty on purpose to please the linter - } + _ = file.Close(); }() // At most, the first 512 bytes of data are used: @@ -118,7 +116,7 @@ func detectContentType(path string) string { } func overrideContentTypeForKnownExtensions(extension, contentType string) string { - if strings.HasPrefix(contentType, plainContentType) == false { + if !strings.HasPrefix(contentType, plainContentType) { return contentType } diff --git a/step.yml b/step.yml index 0540b2de..fd68478c 100644 --- a/step.yml +++ b/step.yml @@ -1,11 +1,11 @@ -title: "Deploy to Bitrise.io - Build Artifacts, Test Reports, and Pipeline intermediate files" +title: Deploy to Bitrise.io - Build Artifacts, Test Reports, and Pipeline intermediate files summary: |- - Deploys build artifacts to make them available for the user on the build's **Artifacts** tab. + Deploys build artifacts to make them available for the user on the build's **Artifacts** tab. Sends test results to the Test Reports add-on (build's **Tests** tab). Uploads Pipeline intermediate files to make them available in subsequent Stages and also uploads Bitrise and user generated html reports. description: |- - The Step accesses artifacts from a directory specified as the `$BITRISE_DEPLOY_DIR` where artifacts generated by previous Steps gets stored. - These artifacts are then uploaded on the **Artifacts** tab of any given build. For installable artifacts, such as IPAs or APKs, the Step can create a public install page that allows testers to install the app on their devices. + The Step accesses artifacts from a directory specified as the `$BITRISE_DEPLOY_DIR` where artifacts generated by previous Steps gets stored. + These artifacts are then uploaded on the **Artifacts** tab of any given build. For installable artifacts, such as IPAs or APKs, the Step can create a public install page that allows testers to install the app on their devices. You can also use the Step to notify users about the build. If you wish to use the Test Reports add-on, you must add this Step in your Workflow since the Step converts test results to the right format and sends them to the add-on. The Step can also share Pipeline intermediate files. These files are build artifacts generated by Workflows in a Pipeline intended to be shared with subsequent Stages. Also it collects and uploads all of the html reports located in the `BITRISE_HTML_REPORT_DIR` folder. @@ -13,70 +13,66 @@ description: |- ### Configuring the Build Artifact Deployment section of the Step 1. Set the value for the **Deploy directory or file path** required input. The default value is the `$BITRISE_DEPLOY_DIR` Env Var which is exposed by the Bitrise CLI. - If you provide a directory, everything in that directory, excluding sub-directories, gets uploaded. - If you provide only a file, then only that file gets uploaded. + If you provide a directory, everything in that directory, excluding sub-directories, gets uploaded. + If you provide only a file, then only that file gets uploaded. To upload a directory's content recursively, you should use the **Compress the artifacts into one file?** which will compress the whole directory, with every sub-directory included. - 2. Set the value of the **Notify: User Roles** input. It sends an email with the [public install URL](https://devcenter.bitrise.io/deploy/bitrise-app-deployment/) to those Bitrise users whose roles are included in this field. + 2. Set the value of the **Notify: User Roles** input. It sends an email with the [public install URL](https://devcenter.bitrise.io/deploy/bitrise-app-deployment/) to those Bitrise users whose roles are included in this field. The default value is `everyone`. If you wish to notify based on user roles, add one or more roles and separate them with commas, for example, `developers`, `admins`. If you don't want to notify anyone, set the input to `none`. - 3. Set the **Notify: Emails** sensitive input. It sends the public install URL in an email to the email addresses provided here. If you’re adding multiple email address, make sure to separate them with commas. + 3. Set the **Notify: Emails** sensitive input. It sends the public install URL in an email to the email addresses provided here. If you’re adding multiple email address, make sure to separate them with commas. The recipients do not have to be in your Bitrise team. Please note that if the email address is associated with a Bitrise account, the user must be [watching](https://devcenter.bitrise.io/builds/configuring-notifications/#watching-an-app) the app. - 4. The **Enable public page for the App?** required input is set to `true` by default. It creates a long and random URL which can be shared with those who do not have a Bitrise account. + 4. The **Enable public page for the App?** required input is set to `true` by default. It creates a long and random URL which can be shared with those who do not have a Bitrise account. If you set this input to `false`, the **Notify: Emails** input will be ignored and the **Notify: User Roles** will receive the build URL instead of the public install URL. 5. With the **Compress the artifacts into one file?** required input set to `true`, you can compress the artifacts found in the Deploy directory into a single file. - You can specify a custom name for the zip file with the `zip_name` option. If you don't specify one, the default `Deploy directory` name will be used. + You can specify a custom name for the zip file with the `zip_name` option. If you don't specify one, the default `Deploy directory` name will be used. If the **Compress the artifacts into one file?** is set to `false`, the artifacts in the Deploy directory will be deployed separately. - 6. With the **Format for the BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP output** required input field, you can customize the output format of the public install page’s multiple artifact URLs so that the next Step can render the output (for example, our **Send a Slack message** Step). + 6. With the **Format for the BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP output** required input field, you can customize the output format of the public install page’s multiple artifact URLs so that the next Step can render the output (for example, our **Send a Slack message** Step). Provide a language template description using [https://golang.org/pkg/text/template](https://golang.org/pkg/text/template) so that the **Deploy to Bitrise.io** Step can build the required custom output. 7. With the **Format for the BITRISE_PERMANENT_DOWNLOAD_URL_MAP output** required input, you can customize the output format of the `BITRISE_PERMANENT_DOWNLOAD_URL_MAP` so that the next Step can render the output. The next Steps will use this input to generate the related output in the specified format. The output contains multiple permanent URLs for multiple artifacts. Provide a language template description using [https://golang.org/pkg/text/template](https://golang.org/pkg/text/template) so that the **Deploy to Bitrise.io** Step can build the required custom output. 8. The **Test API's base URL** and the **API Token** input fields are automatically populated for you. 9. The html report upload does not have any specific settings because it will happen automatically. - + ### Configuring the Pipeline Intermediate File Sharing section of the Step - + The **Files to share between pipeline stages** input specifies the files meant to be intermediate files shared between the Pipeline Stages. When uploading the Pipeline intermediate files, you must assign environment variable keys to them in the **Files to share between pipeline stages** input. - The inputs `path:env_key` values will be saved together with the file and later automatically reconstructed by the [Pull Pipeline intermediate files Step](https://www.bitrise.io/integrations/steps/pull-intermediate-files). + The inputs `path:env_key` values will be saved together with the file and later automatically reconstructed by the [Pull Pipeline intermediate files Step](https://www.bitrise.io/integrations/steps/pull-intermediate-files). You can use a shorthand of just `env_var` for `$env_var:env_var`, when the `env_var` holds the path to the file(s) you want to share with subsequent stages. The directories you specify will be archived and uploaded as a single file. - + #### Configuring the Debug section of the Step - + If you wish to use any of the Step’s debug features, set the following inputs: 1. In the **Name of the compressed artifact (without .zip extension)** input you can add a custom name for the compressed artifact. If you leave this input empty, the default `Deploy directory` name is used. Please note that this input only works if you set the **Compress the artifacts into one file?** input to `true`. 2. The **Bitrise Build URL** and the **Bitrise Build API Token** inputs are automatically populated. - 3. If **The Enable Debug Mode** required input is set to `true`, the Step prints more verbose logs. It is `false` by default. - 4. If you need a specific [bundletool version](https://github.com/google/bundletool/releases) other than the default value, you can modify the value of the **Bundletool version** required input. + 3. If **The Enable Debug Mode** required input is set to `true`, the Step prints more verbose logs. It is `false` by default. + 4. If you need a specific [bundletool version](https://github.com/google/bundletool/releases) other than the default value, you can modify the value of the **Bundletool version** required input. Bundletool generates an APK from an Android App Bundle so that you can test the APK. ### Troubleshooting - + - If your users did not get notified via email, check the **Enable public page for the App?** input. If it is set to `false`, no email notifications will be sent. - - If there are no artifacts uploaded on the **APPS & ARTIFACTS tab**, then check the logs to see if the directory you used in the **Deploy directory or file path** input contained any artifacts. + - If there are no artifacts uploaded on the **APPS & ARTIFACTS tab**, then check the logs to see if the directory you used in the **Deploy directory or file path** input contained any artifacts. - If the email is not received, we recommend, that you check if the email is associated with Bitrise account and if so, if the account is “watching” the app. - + ### Useful links - + - [Deployment on Bitrise](https://devcenter.bitrise.io/deploy/deployment-index/) - [Watching an app](https://devcenter.bitrise.io/builds/configuring-notifications/#watching-an-app) - [Using artifacts from different Stages](https://devcenter.bitrise.io/en/builds/build-pipelines/configuring-a-bitrise-pipeline.html#using-artifacts-from-different-stages) - [Viewing HTML reports](https://devcenter.bitrise.io/en/builds/build-data-and-troubleshooting/viewing-html-reports) - + ### Related Steps - + - [Deploy to Google Play](https://www.bitrise.io/integrations/steps/google-play-deploy) - [Deploy to iTunesConnect](https://www.bitrise.io/integrations/steps/deploy-to-itunesconnect-deliver) - [Pull Pipeline intermediate files](https://www.bitrise.io/integrations/steps/pull-intermediate-files) website: https://github.com/bitrise-steplib/steps-deploy-to-bitrise-io source_code_url: https://github.com/bitrise-steplib/steps-deploy-to-bitrise-io support_url: https://github.com/bitrise-steplib/steps-deploy-to-bitrise-io/issues -host_os_tags: - - "osx-10.10" -project_type_tags: [] type_tags: - - deploy -is_requires_admin_user: false +- deploy is_always_run: true is_skippable: false run_if: .IsCI @@ -84,286 +80,284 @@ toolkit: go: package_name: github.com/bitrise-steplib/steps-deploy-to-bitrise-io inputs: - - deploy_path: "$BITRISE_DEPLOY_DIR" - opts: - category: Build Artifact Deployment - title: "Deploy directory or file path" - description: | - Specify the directory or file path which will be deployed. - - If the specified path is a directory, then every file - in the specified directory, excluding sub-directories, will be deployed. - - To upload the directory's content - recursively, you should use the **Compress the artifacts into one file?** option - which compresses the whole directory, with - every sub-directory included. - - If you specify a file path, then only the specified - file will be deployed. - - is_compress: "false" - opts: - category: Build Artifact Deployment - title: Compress the artifacts into one file? - summary: |- - If this option is set to `true` and a Deploy directory was specified, - the artifacts in that directory will be compressed into a single ZIP file. - description: |- - If this option is set to `true` and a Deploy directory was specified, - the artifacts in that directory will be compressed into a single ZIP file. - - You can specify a custom name for the ZIP using the `zip_name` - option. If you do not specify a custom name, the default `Deploy directory` name will be used. - - If this option is set to `false`, the artifacts - found in the Deploy directory folder will be deployed - separately. - is_required: true - is_expand: false - value_options: - - "true" - - "false" - - zip_name: - opts: - category: Build Artifact Deployment - title: Name of the compressed artifact (without .zip extension) - summary: |- - Specify a custom name for the compressed artifact. - description: |- - If you do not specify a custom name, the Deploy directory name will be used. - You can specify a custom name for the ZIP using the `zip_name` - option. - - This option only works if you selected *true* for *is_compress*. - - notify_user_groups: "everyone" - opts: - category: Build Artifact Deployment - title: "Notify: User Roles" - description: | - Your App's user roles you want to notify. Separate the role names with commas. - Possible role names: - - * none - * testers - * developers - * admins - * owner - * everyone - - An example to notify your developers and testers: - - `testers, developers` - - If you want to notify everyone in the app's team, just specify `everyone`. - - If you don't want to notify anyone, set this to `none`. - - notify_email_list: - opts: - category: Build Artifact Deployment - title: "Notify: Emails" - description: | - Email addresses to notify. Separate them with commas. - - You can specify any email address, the recipients - don't have to be in your team. - - Please note that if the email address is associated with a Bitrise account, - the user must be [watching](https://devcenter.bitrise.io/builds/configuring-notifications/#watching-an-app) the app. - is_sensitive: true - - is_enable_public_page: "true" - opts: - category: Build Artifact Deployment - title: "Enable public page for the App?" - description: | - If this option is enabled, a public install page - will be available with a long and random URL which can be shared - with others who are not registered on Bitrise. - - If you disable this option, the **Notify: Emails** option will - be ignored and the **Notify: User Roles** users will receive the build's - URL instead of the public page's URL! - is_required: true - is_expand: false - value_options: - - "true" - - "false" - - bundletool_version: "1.15.0" - opts: - category: Build Artifact Deployment - title: "Bundletool version" - summary: The specific bundletool version you want to use. - description: |- - If you need a specific [bundletool version]((https://github.com/google/bundletool/releases) other than the default version, - you can modify the value of the **Bundletool version** required input. - is_required: true - - build_url: "$BITRISE_BUILD_URL" - opts: - category: Build Artifact Deployment - title: "Bitrise Build URL" - summary: |- - Unique build URL of this build on Bitrise.io - description: |- - Unique build URL of this build on Bitrise.io - is_required: true - is_dont_change_value: true - - build_api_token: "$BITRISE_BUILD_API_TOKEN" - opts: - category: Build Artifact Deployment - title: Bitrise Build API Token - summary: |- - The build's API Token for the build on Bitrise.io - description: |- - The build's API Token for the build on Bitrise.io - is_required: true - is_dont_change_value: true - is_sensitive: true - - pipeline_intermediate_files: - opts: - category: Pipeline Intermediate File Sharing - title: Files to share between pipeline stages - summary: |- - A newline (`\n`) separated list of file path - env key pairs (`{path}:{env_key}`). - description: |- - A newline (`\n`) separated list of file path - env key pairs (`{path}:{env_key}`). - - The input uses a `{path}:{env_key}` syntax. - The colon character (`:`) is the delimiter between the file path and the environment variable key. - A shorthand syntax of `ENV_VAR` can be used for `$ENV_VAR:ENV_VAR` when the name of the env var in the current workflow will become the shared env_key. - - The file path can be specified with environment variables or direct paths, - and can point to both a local file or directory: - ``` - $BITRISE_IPA_PATH:BITRISE_IPA_PATH - BITRISE_IPA_PATH - $BITRISE_APK_PATH:DEVELOPMENT_APK_PATH - ./path/to/test_reports:TEST_REPORTS_DIR - $BITRISE_SOURCE_DIR/deploy_dir:DEPLOY_DIR - ``` - - addon_api_base_url: "https://vdt.bitrise.io/test" - opts: - category: Test Reports Addon - title: "Test API's base URL" - summary: The URL where test API is accessible. - description: | - The URL where test API is accessible. - is_required: true - is_dont_change_value: true - - addon_api_token: $ADDON_VDTESTING_API_TOKEN - opts: - category: Test Reports Addon - title: "API Token" - summary: The token required to authenticate with the API. - description: | - The token required to authenticate with the API. - is_dont_change_value: true - is_sensitive: true - - public_install_page_url_map_format: "{{range $index, $element := .}}{{if $index}}|{{end}}{{$element.File}}=>{{$element.URL}}{{end}}" - opts: - category: Step output configuration - title: Format for the BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP output - summary: You can customize the format of the `BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP` output so that the next Step can render the output. - description: |- - Provide a language template description using [Golang templates](https://golang.org/pkg/text/template) - so that the **Deploy to Bitrise.io** Step can build the required custom output. - is_required: true - is_expand: false - - permanent_download_url_map_format: "{{range $index, $element := .}}{{if $index}}|{{end}}{{$element.File}}=>{{$element.URL}}{{end}}" - opts: - category: Step output configuration - title: Format for the BITRISE_PERMANENT_DOWNLOAD_URL_MAP output - summary: You can customize the format of the `BITRISE_PERMANENT_DOWNLOAD_URL_MAP` output so that the next Step can render the output. - description: |- - Provide a language template description using [Golang templates](https://golang.org/pkg/text/template) - so that the **Deploy to Bitrise.io** Step can build the required custom output for the permanent download URL. - is_required: true - is_expand: false - - details_page_url_map_format: "{{range $index, $element := .}}{{if $index}}|{{end}}{{$element.File}}=>{{$element.URL}}{{end}}" - opts: - category: Step output configuration - title: Format for the BITRISE_ARTIFACT_DETAILS_PAGE_URL_MAP output - summary: You can customize the format of the `BITRISE_ARTIFACT_DETAILS_PAGE_URL_MAP` output so that the next Step can render the output. - description: |- - Provide a language template description using [Golang templates](https://golang.org/pkg/text/template) - so that the **Deploy to Bitrise.io** Step can build the required custom output for the details page URL. - is_required: true - is_expand: false - - files_to_redact: - opts: - title: Files to redact - description: |- - A newline (`\n`) separated list of file paths to redact secrets from before the step deploys them. - summary: |- - A newline (`\n`) separated list of file paths to redact secrets from before the step deploys them. - - The file path can be specified with environment variables or direct paths: - ``` - $XCODE_BUILD_RAW_RESULT_TEXT_PATH - ./path/to/build_log.xml - ``` - - The step will fail (and potentially also fail the build) if there is any error during the redaction process. - This will prevent secrets in files accidentally leaking out of builds. - is_required: false - - debug_mode: "false" - opts: - category: Debugging - title: "Enable Debug Mode" - summary: The Step will print more verbose logs if enabled. - description: The Step will print more verbose logs if enabled. - is_required: true - value_options: - - "false" - - "true" +- deploy_path: $BITRISE_DEPLOY_DIR + opts: + category: Build Artifact Deployment + title: Deploy directory or file path + description: | + Specify the directory or file path which will be deployed. + + If the specified path is a directory, then every file + in the specified directory, excluding sub-directories, will be deployed. + + To upload the directory's content + recursively, you should use the **Compress the artifacts into one file?** option + which compresses the whole directory, with + every sub-directory included. + + If you specify a file path, then only the specified + file will be deployed. +- is_compress: "false" + opts: + category: Build Artifact Deployment + title: Compress the artifacts into one file? + summary: |- + If this option is set to `true` and a Deploy directory was specified, + the artifacts in that directory will be compressed into a single ZIP file. + description: |- + If this option is set to `true` and a Deploy directory was specified, + the artifacts in that directory will be compressed into a single ZIP file. + + You can specify a custom name for the ZIP using the `zip_name` + option. If you do not specify a custom name, the default `Deploy directory` name will be used. + + If this option is set to `false`, the artifacts + found in the Deploy directory folder will be deployed + separately. + is_required: true + is_expand: false + value_options: + - "true" + - "false" +- zip_name: + opts: + category: Build Artifact Deployment + title: Name of the compressed artifact (without .zip extension) + summary: |- + Specify a custom name for the compressed artifact. + description: |- + If you do not specify a custom name, the Deploy directory name will be used. + You can specify a custom name for the ZIP using the `zip_name` option. + + This option only works if you selected *true* for *is_compress*. +- notify_user_groups: everyone + opts: + category: Build Artifact Deployment + title: "Notify: User Roles" + description: | + Your App's user roles you want to notify. Separate the role names with commas. + Possible role names: + + * none + * testers + * developers + * admins + * owner + * everyone + + An example to notify your developers and testers: + + `testers, developers` + + If you want to notify everyone in the app's team, just specify `everyone`. + + If you don't want to notify anyone, set this to `none`. +- notify_email_list: + opts: + category: Build Artifact Deployment + title: "Notify: Emails" + description: | + Email addresses to notify. Separate them with commas. + + You can specify any email address, the recipients + don't have to be in your team. + + Please note that if the email address is associated with a Bitrise account, + the user must be [watching](https://devcenter.bitrise.io/builds/configuring-notifications/#watching-an-app) the app. + is_sensitive: true +- is_enable_public_page: "true" + opts: + category: Build Artifact Deployment + title: Enable public page for the App? + description: | + If this option is enabled, a public install page + will be available with a long and random URL which can be shared + with others who are not registered on Bitrise. + + If you disable this option, the **Notify: Emails** option will + be ignored and the **Notify: User Roles** users will receive the build's + URL instead of the public page's URL! + is_required: true + is_expand: false + value_options: + - "true" + - "false" +- bundletool_version: 1.15.0 + opts: + category: Build Artifact Deployment + title: Bundletool version + summary: The specific bundletool version you want to use. + description: |- + If you need a specific [bundletool version]((https://github.com/google/bundletool/releases) other than the default version, you can modify the value of the **Bundletool version** required input. + is_required: true +- build_url: $BITRISE_BUILD_URL + opts: + category: Build Artifact Deployment + title: Bitrise Build URL + summary: |- + Unique build URL of this build on Bitrise.io + description: |- + Unique build URL of this build on Bitrise.io + is_required: true + is_dont_change_value: true +- build_api_token: $BITRISE_BUILD_API_TOKEN + opts: + category: Build Artifact Deployment + title: Bitrise Build API Token + summary: |- + The build's API Token for the build on Bitrise.io + description: |- + The build's API Token for the build on Bitrise.io + is_required: true + is_dont_change_value: true + is_sensitive: true +- pipeline_intermediate_files: + opts: + category: Pipeline Intermediate File Sharing + title: Files to share between pipeline stages + summary: |- + A newline (`\n`) separated list of file path - env key pairs (`{path}:{env_key}`). + description: |- + A newline (`\n`) separated list of file path - env key pairs (`{path}:{env_key}`). + + The input uses a `{path}:{env_key}` syntax. + The colon character (`:`) is the delimiter between the file path and the environment variable key. + A shorthand syntax of `ENV_VAR` can be used for `$ENV_VAR:ENV_VAR` when the name of the env var in the current workflow will become the shared env_key. + + The file path can be specified with environment variables or direct paths, + and can point to both a local file or directory: + ``` + $BITRISE_IPA_PATH:BITRISE_IPA_PATH + BITRISE_IPA_PATH + $BITRISE_APK_PATH:DEVELOPMENT_APK_PATH + ./path/to/test_reports:TEST_REPORTS_DIR + $BITRISE_SOURCE_DIR/deploy_dir:DEPLOY_DIR + ``` +- addon_api_base_url: https://vdt.bitrise.io/test + opts: + category: Test Reports Addon + title: Test API's base URL + summary: The URL where test API is accessible. + description: | + The URL where test API is accessible. + is_required: true + is_dont_change_value: true +- addon_api_token: $ADDON_VDTESTING_API_TOKEN + opts: + category: Test Reports Addon + title: API Token + summary: The token required to authenticate with the API. + description: | + The token required to authenticate with the API. + is_dont_change_value: true + is_sensitive: true +- public_install_page_url_map_format: "{{range $index, $element := .}}{{if $index}}|{{end}}{{$element.File}}=>{{$element.URL}}{{end}}" + opts: + category: Step output configuration + title: Format for the BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP output + summary: You can customize the format of the `BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP` output so that the next Step can render the output. + description: |- + Provide a language template description using [Golang templates](https://golang.org/pkg/text/template) + so that the **Deploy to Bitrise.io** Step can build the required custom output. + is_required: true + is_expand: false +- permanent_download_url_map_format: "{{range $index, $element := .}}{{if $index}}|{{end}}{{$element.File}}=>{{$element.URL}}{{end}}" + opts: + category: Step output configuration + title: Format for the BITRISE_PERMANENT_DOWNLOAD_URL_MAP output + summary: You can customize the format of the `BITRISE_PERMANENT_DOWNLOAD_URL_MAP` output so that the next Step can render the output. + description: |- + Provide a language template description using [Golang templates](https://golang.org/pkg/text/template) + so that the **Deploy to Bitrise.io** Step can build the required custom output for the permanent download URL. + is_required: true + is_expand: false +- details_page_url_map_format: "{{range $index, $element := .}}{{if $index}}|{{end}}{{$element.File}}=>{{$element.URL}}{{end}}" + opts: + category: Step output configuration + title: Format for the BITRISE_ARTIFACT_DETAILS_PAGE_URL_MAP output + summary: You can customize the format of the `BITRISE_ARTIFACT_DETAILS_PAGE_URL_MAP` output so that the next Step can render the output. + description: |- + Provide a language template description using [Golang templates](https://golang.org/pkg/text/template) + so that the **Deploy to Bitrise.io** Step can build the required custom output for the details page URL. + is_required: true + is_expand: false +- files_to_redact: + opts: + title: Files to redact + description: |- + A newline (`\n`) separated list of file paths to redact secrets from before the step deploys them. + summary: |- + A newline (`\n`) separated list of file paths to redact secrets from before the step deploys them. + + The file path can be specified with environment variables or direct paths: + ``` + $XCODE_BUILD_RAW_RESULT_TEXT_PATH + ./path/to/build_log.xml + ``` + + The step will fail (and potentially also fail the build) if there is any error during the redaction process. + This will prevent secrets in files accidentally leaking out of builds. + is_required: false +- debug_mode: "false" + opts: + category: Debugging + title: Enable Debug Mode + summary: The Step will print more verbose logs if enabled. + description: The Step will print more verbose logs if enabled. + is_required: true + value_options: + - "false" + - "true" outputs: - - BITRISE_PUBLIC_INSTALL_PAGE_URL: - opts: - title: Public Install Page URL - description: |- - Public Install Page's URL, if the - *Enable public page for the App?* option was *enabled*. - - BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP: - opts: - title: Map of filenames and Public Install Page URLs - description: |- - Public Install Page URLs by the artifact's file path. - Only set it if the *Enable public page for the App?* option was *enabled*. - - The default format is `KEY1=>VALUE|KEY2=>VALUE` but is controlled by the `public_install_page_url_map_format` input - - Examples: - - - $BITRISE_DEPLOY_DIR/ios_app.ipa=>https://ios_app/public/install/page - - $BITRISE_DEPLOY_DIR/android_app.apk=>https://android_app/public/install/page|$BITRISE_DEPLOY_DIR/ios_app.ipa=>https://ios_app/public/install/page - - BITRISE_PERMANENT_DOWNLOAD_URL_MAP: - opts: - title: Map of filenames and Permanent Download URLs - description: |- - The output contains permanent Download URLs for each artifact. The URLs can be shared in any communication channel and they won't expire. - The default format is `KEY1=>VALUE|KEY2=>VALUE` where key is the filename and the value is the URL. - If you change `permanent_download_url_map_format` input then that will modify the format of this Env Var. - You can customize the format of the multiple URLs. - - Examples: - - - $BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/artifacts/ipa-slug/download - - $BITRISE_DEPLOY_DIR/android_app.apk=>https://app.bitrise.io/artifacts/apk-slug/download|$BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/artifacts/ipa-slug/download - - - BITRISE_ARTIFACT_DETAILS_PAGE_URL: - opts: - title: Details Page URL - description: |- - Details Page's URL. - - At the moment, only installable artifacts (.aab, .apk, .ipa) have details page URL. - - BITRISE_ARTIFACT_DETAILS_PAGE_URL_MAP: - opts: - title: Map of filenames and Public Install Page URLs - description: |- - Details Page URLs by the artifact's path. - - The default format is `KEY1=>VALUE\|KEY2=>VALUE` but is controlled by the `details_page_url_map_format` input - - Examples: - - - $BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/apps/ios_app/installable-artifacts/ipa-slug - - $BITRISE_DEPLOY_DIR/android_app.apk=>https://app.bitrise.io/apps/android_app/installable-artifacts/apk-slug|$BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/apps/ios_app/installable-artifacts/ipa-slug \ No newline at end of file +- BITRISE_PUBLIC_INSTALL_PAGE_URL: + opts: + title: Public Install Page URL + description: |- + Public Install Page's URL, if the + *Enable public page for the App?* option was *enabled*. +- BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP: + opts: + title: Map of filenames and Public Install Page URLs + description: |- + Public Install Page URLs by the artifact's file path. + Only set it if the *Enable public page for the App?* option was *enabled*. + + The default format is `KEY1=>VALUE|KEY2=>VALUE` but is controlled by the `public_install_page_url_map_format` input + + Examples: + + - $BITRISE_DEPLOY_DIR/ios_app.ipa=>https://ios_app/public/install/page + - $BITRISE_DEPLOY_DIR/android_app.apk=>https://android_app/public/install/page|$BITRISE_DEPLOY_DIR/ios_app.ipa=>https://ios_app/public/install/page +- BITRISE_PERMANENT_DOWNLOAD_URL_MAP: + opts: + title: Map of filenames and Permanent Download URLs + description: |- + The output contains permanent Download URLs for each artifact. The URLs can be shared in any communication channel and they won't expire. + The default format is `KEY1=>VALUE|KEY2=>VALUE` where key is the filename and the value is the URL. + If you change `permanent_download_url_map_format` input then that will modify the format of this Env Var. + You can customize the format of the multiple URLs. + + Examples: + + - $BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/artifacts/ipa-slug/download + - $BITRISE_DEPLOY_DIR/android_app.apk=>https://app.bitrise.io/artifacts/apk-slug/download|$BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/artifacts/ipa-slug/download + +- BITRISE_ARTIFACT_DETAILS_PAGE_URL: + opts: + title: Details Page URL + description: |- + Details Page's URL. + + At the moment, only installable artifacts (.aab, .apk, .ipa) have details page URL. +- BITRISE_ARTIFACT_DETAILS_PAGE_URL_MAP: + opts: + title: Map of filenames and Public Install Page URLs + description: |- + Details Page URLs by the artifact's path. + + The default format is `KEY1=>VALUE\|KEY2=>VALUE` but is controlled by the `details_page_url_map_format` input + + Examples: + + - $BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/apps/ios_app/installable-artifacts/ipa-slug + - $BITRISE_DEPLOY_DIR/android_app.apk=>https://app.bitrise.io/apps/android_app/installable-artifacts/apk-slug|$BITRISE_DEPLOY_DIR/ios_app.ipa=>https://app.bitrise.io/apps/ios_app/installable-artifacts/ipa-slug diff --git a/test/converters/junitxml/junitxml.go b/test/converters/junitxml/junitxml.go index 9927ac9e..26b25af6 100644 --- a/test/converters/junitxml/junitxml.go +++ b/test/converters/junitxml/junitxml.go @@ -2,7 +2,7 @@ package junitxml import ( "encoding/xml" - "io/ioutil" + "os" "strings" "github.com/bitrise-steplib/steps-deploy-to-bitrise-io/test/junit" @@ -18,7 +18,7 @@ type fileReader struct { } func (r *fileReader) ReadAll() ([]byte, error) { - return ioutil.ReadFile(r.Filename) + return os.ReadFile(r.Filename) } type stringReader struct { diff --git a/test/converters/xcresult/xcresult.go b/test/converters/xcresult/xcresult.go index da3db6f6..6ee9d4b0 100644 --- a/test/converters/xcresult/xcresult.go +++ b/test/converters/xcresult/xcresult.go @@ -23,7 +23,7 @@ func (h *Converter) Detect(files []string) bool { for _, file := range h.files { if filepath.Ext(file) == ".xcresult" { testSummariesPlistPath := filepath.Join(file, "TestSummaries.plist") - if exist, err := pathutil.IsPathExists(testSummariesPlistPath); err != nil || exist == false { + if exist, err := pathutil.IsPathExists(testSummariesPlistPath); err != nil || !exist { continue } diff --git a/test/test.go b/test/test.go index 210e4c97..cd3a5ed3 100644 --- a/test/test.go +++ b/test/test.go @@ -6,7 +6,6 @@ import ( "encoding/xml" "fmt" "io" - "io/ioutil" "net/http" "os" "path/filepath" @@ -81,7 +80,7 @@ func httpCall(apiToken, method, url string, input io.Reader, output interface{}, }() if resp.StatusCode < 200 || 299 < resp.StatusCode { - bodyData, err := ioutil.ReadAll(resp.Body) + bodyData, err := io.ReadAll(resp.Body) if err != nil { logger.Warnf("Failed to read response: %s", err) return fmt.Errorf("unsuccessful status code: %d", resp.StatusCode) @@ -134,7 +133,7 @@ func ParseTestResults(testsRootDir string, logger logV2.Logger) (results Results // read dirs in base tests dir // - testDirs, err := ioutil.ReadDir(testsRootDir) + testDirs, err := os.ReadDir(testsRootDir) if err != nil { return nil, err } @@ -150,7 +149,7 @@ func ParseTestResults(testsRootDir string, logger logV2.Logger) (results Results } // read unique test phase dirs - testPhaseDirs, err := ioutil.ReadDir(testDirPath) + testPhaseDirs, err := os.ReadDir(testDirPath) if err != nil { return nil, err } diff --git a/test/test_test.go b/test/test_test.go index 85b57aaa..8a2cd724 100644 --- a/test/test_test.go +++ b/test/test_test.go @@ -2,7 +2,7 @@ package test import ( "encoding/json" - "io/ioutil" + "io" "net/http" "os" "path" @@ -57,21 +57,21 @@ func Test_Upload(t *testing.T) { }, } - go func() { + go func() { //nolint:staticcheck // We should fix it one day, but it requires a bigger refactor router := mux.NewRouter() router.HandleFunc("/test/apps/{app_slug}/builds/{build_slug}/test_reports/{accessToken}", func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) if _, ok := vars["app_slug"]; !ok { - t.Fatal("app_slug must be specified") + t.Fatal("app_slug must be specified") //nolint:govet // We should fix it one day, but it requires a bigger refactor } if _, ok := vars["build_slug"]; !ok { - t.Fatal("build_slug must be specified") + t.Fatal("build_slug must be specified") //nolint:govet // We should fix it one day, but it requires a bigger refactor } var uploadReq UploadRequest if err := json.NewDecoder(r.Body).Decode(&uploadReq); err != nil { - t.Fatal("failed to execute get request, error:", err) + t.Fatal("failed to execute get request, error:", err) //nolint:govet // We should fix it one day, but it requires a bigger refactor } response := UploadResponse{ @@ -88,10 +88,10 @@ func Test_Upload(t *testing.T) { b, err := json.Marshal(response) if err != nil { - t.Fatal(err) + t.Fatal(err) //nolint:govet // We should fix it one day, but it requires a bigger refactor } if _, err := w.Write(b); err != nil { - t.Fatal("Failed to write to the writer, error:", err) + t.Fatal("Failed to write to the writer, error:", err) //nolint:govet // We should fix it one day, but it requires a bigger refactor } }).Methods("POST") @@ -99,12 +99,12 @@ func Test_Upload(t *testing.T) { vars := mux.Vars(r) fName, ok := vars["file_name"] if !ok { - t.Fatal("file_name must be specified") + t.Fatal("file_name must be specified") //nolint:govet // We should fix it one day, but it requires a bigger refactor } - receivedData, err := ioutil.ReadAll(r.Body) + receivedData, err := io.ReadAll(r.Body) if err != nil { - t.Fatal(err) + t.Fatal(err) //nolint:govet // We should fix it one day, but it requires a bigger refactor } if fName == "test_result.xml" { @@ -118,11 +118,11 @@ func Test_Upload(t *testing.T) { if filepath.Base(assetPath) == fName { fileData, err := fileutil.ReadStringFromFile(assetPath) if err != nil { - t.Fatal(err) + t.Fatal(err) //nolint:govet // We should fix it one day, but it requires a bigger refactor } if fileData != string(receivedData) { - t.Fatal("files are not the same!") + t.Fatal("files are not the same!") //nolint:govet // We should fix it one day, but it requires a bigger refactor } w.WriteHeader(http.StatusOK) @@ -136,14 +136,14 @@ func Test_Upload(t *testing.T) { router.HandleFunc("/test/apps/{app_slug}/builds/{build_slug}/test_reports/{id}/{accessToken}", func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) if _, ok := vars["app_slug"]; !ok { - t.Fatal("app_slug must be specified") + t.Fatal("app_slug must be specified") //nolint:govet // We should fix it one day, but it requires a bigger refactor } if _, ok := vars["build_slug"]; !ok { - t.Fatal("build_slug must be specified") + t.Fatal("build_slug must be specified") //nolint:govet // We should fix it one day, but it requires a bigger refactor } id, ok := vars["id"] if !ok { - t.Fatal("id must be specified") + t.Fatal("id must be specified") //nolint:govet // We should fix it one day, but it requires a bigger refactor } if id != testResponseID { @@ -152,7 +152,7 @@ func Test_Upload(t *testing.T) { }).Methods("PATCH") - t.Fatal(http.ListenAndServe(":8893", router)) + t.Fatal(http.ListenAndServe(":8893", router)) //nolint:staticcheck,govet // We should fix it one day, but it requires a bigger refactor }() time.Sleep(time.Second) @@ -312,6 +312,7 @@ func Test_ParseXctest3Results(t *testing.T) { require.NoError(t, err) want, err := fileutil.ReadStringFromFile(filepath.Join("testdata", "ios_device_config_xml_output.golden")) + require.NoError(t, err) assert.Equal(t, 1, len(bundle)) assert.Equal(t, want, string(bundle[0].XMLContent)) diff --git a/uploaders/common.go b/uploaders/common.go index c8625b80..cb0ee4c3 100644 --- a/uploaders/common.go +++ b/uploaders/common.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -100,7 +99,7 @@ func createArtifact(buildURL, token, artifactPth, artifactType, contentType stri } }() - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) if err != nil { return fmt.Errorf("failed to read create artifact response, error: %s", err) } @@ -163,7 +162,7 @@ func UploadArtifact(uploadURL, artifactPth, contentType string) error { // Initializes request body to nil to send a Content-Length of 0: https://github.com/golang/go/issues/20257#issuecomment-299509391 var reqBody io.Reader if fileInfo.Size() > 0 { - reqBody = ioutil.NopCloser(file) + reqBody = io.NopCloser(file) } request, err := http.NewRequest(http.MethodPut, uploadURL, reqBody) @@ -193,7 +192,7 @@ func UploadArtifact(uploadURL, artifactPth, contentType string) error { } }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read response body, error: %s", err) } @@ -274,7 +273,7 @@ func finishArtifact(buildURL, token, artifactID string, appDeploymentMeta *AppDe }() // process response - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) if err != nil { return fmt.Errorf("failed to read finish artifact response, error: %s", err) } diff --git a/uploaders/common_test.go b/uploaders/common_test.go index e637be89..d33961a1 100644 --- a/uploaders/common_test.go +++ b/uploaders/common_test.go @@ -1,9 +1,10 @@ package uploaders import ( + "os" + "io" "image" "image/png" - "io/ioutil" "math/rand" "net/http" "net/http/httptest" @@ -15,7 +16,7 @@ import ( func Test_uploadArtifact(t *testing.T) { const contentType = "image/png" - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") if err != nil { t.Fatalf("setup: failed to create file, error: %s", err) } @@ -47,7 +48,7 @@ func Test_uploadArtifact(t *testing.T) { t.Logf("Content type: %s", r.Header.Get("Content-Type")) - bytes, err := ioutil.ReadAll(r.Body) + bytes, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("httptest: failed to read request, error: %s", err) return