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

Config pipeline #1005

Merged
merged 46 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
90cdc8c
Update bitrise.yml
godrei Sep 17, 2024
73eb9f6
Test on macos and linux and add release workflow
godrei Sep 17, 2024
b853e00
Lock steps on major versions
godrei Sep 17, 2024
e2f6eae
Fix goreleaser setup
godrei Sep 17, 2024
eced161
Update binary build tests
godrei Sep 17, 2024
abbe773
Remove yaml lint setup
godrei Sep 17, 2024
96dcc99
Fix yaml lint issues
godrei Sep 17, 2024
d85a229
Deploy integration tests
godrei Sep 17, 2024
c6b93f3
Add some todos, run linux integration tests on ubuntu-20.4 and print …
godrei Sep 17, 2024
c4d4fe6
Fix junit reporter
godrei Sep 17, 2024
205a77c
Deploy unit test results
godrei Sep 17, 2024
955a5f4
Lint issue fixes
godrei Sep 17, 2024
15577ae
Fix lint issue
godrei Sep 18, 2024
a214b24
Fix linux integration tests
godrei Sep 18, 2024
cd816e4
Update unit_test bundle
godrei Sep 18, 2024
dbf88ed
CI fixes
godrei Sep 18, 2024
1aa3480
Fix go tool installation on Ubuntu stacks
godrei Sep 19, 2024
c9c44af
Create test result files
godrei Sep 19, 2024
e7686be
Fix unit tests
godrei Sep 27, 2024
15cc547
Fix linux integration tests
godrei Sep 27, 2024
d2f3853
Fix unit test command
godrei Sep 30, 2024
37b1053
Fix lint issue
godrei Sep 30, 2024
9b12bb8
Debug unit test result dir
godrei Sep 30, 2024
682e5ee
Improve unit test bundle
godrei Oct 1, 2024
89db513
Update go test scripts
godrei Oct 1, 2024
4275549
debug unit test reults
godrei Oct 1, 2024
344cee2
Update
godrei Oct 1, 2024
1f53974
Fix
godrei Oct 1, 2024
4b040e9
Fix
godrei Oct 1, 2024
a1e10a2
Update run_unit_tests step bundle
godrei Oct 2, 2024
bf55c07
Fix unit tests and improve ui test bundles
godrei Oct 2, 2024
859f11c
Fix yaml lint issues
godrei Oct 2, 2024
27e2569
Update tests
godrei Oct 2, 2024
4e24593
Fix integration tests
godrei Oct 2, 2024
0a5458c
Fix yaml lint issues
godrei Oct 2, 2024
7447607
Add new create-release workflow and create step bundles for setup_go_…
godrei Oct 24, 2024
3fd5cc1
Merge branch 'master' into config-pipeline
godrei Oct 24, 2024
1f070c9
Fix lint issue and go-junit-report installation
godrei Oct 24, 2024
36828ae
Fix asdf reshim
godrei Oct 24, 2024
1b9fd9f
Fix asdf command
godrei Oct 24, 2024
6eef161
Fix asdf reshim
godrei Oct 24, 2024
9d3fafd
Separate run_docker_integration_tests
godrei Oct 24, 2024
9554c2f
Fix lint issue
godrei Oct 24, 2024
a5d9d7d
Use latest xcode stack and simplify go-junit-report installation
godrei Nov 4, 2024
e346a99
Restore local testing workflows
godrei Nov 5, 2024
945ccd8
Fix os-xcode stack name
godrei Nov 13, 2024
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
349 changes: 295 additions & 54 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,116 @@
format_version: "11"
---
format_version: "17"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other

app:
envs:
- BIN_NAME: bitrise
trigger_map:
- push_branch: master
pipeline: ci
- pull_request_source_branch: "*"
pipeline: ci
- tag: "*.*.*"
workflow: release
enabled: false

pipelines:
ci:
stages:
- run_tests: { }

stages:
run_tests:
workflows:
- run_lint: { }
- run_unit_tests_macos: { }
- run_unit_tests_linux: { }
- run_integration_tests_macos: { }
- run_integration_tests_linux: { }
- run_docker_integration_tests_linux: { }
- test_binary_build_macos: { }
- test_binary_build_linux: { }

workflows:
check:
run_lint:
steps:
- git::https://github.com/bitrise-steplib/steps-check.git:
inputs:
- workflow: lint
- skip_step_yml_validation: "yes"
- go-list: { }
- script:
title: Go test
inputs:
- content: go test -p 1 $BITRISE_GO_PACKAGES
- bundle::run_lint: { }

test:
title: Runs tests
after_run:
- check
- integration-test
run_unit_tests_macos:
steps:
- bundle::setup_go_junit_report: { }
- bundle::run_unit_tests: { }
meta:
bitrise.io:
stack: osx-xcode-16.0.x
machine_type_id: g2.mac.large

integration-test:
title: Runs integration tests
run_unit_tests_linux:
steps:
- script:
title: Run integration tests
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
- bundle::setup_go_junit_report: { }
- bundle::run_unit_tests: { }
meta:
bitrise.io:
machine_type_id: elite-xl
stack: linux-docker-android-22.04

current_bitrise="$(pwd)/_tmp/test_bitrise"
export CGO_ENABLED=0
go build -o "$current_bitrise"
run_integration_tests_macos:
steps:
- bundle::setup_go_junit_report: { }
- bundle::run_integration_tests: { }
meta:
bitrise.io:
stack: osx-xcode-edge
machine_type_id: g2.mac.large

export PR="" PULL_REQUEST_ID=""
export INTEGRATION_TEST_BINARY_PATH="$current_bitrise"
run_integration_tests_linux:
steps:
- bundle::setup_go_junit_report: { }
- bundle::run_integration_tests: { }
meta:
bitrise.io:
machine_type_id: elite-xl
stack: linux-docker-android-22.04

$current_bitrise setup
run_docker_integration_tests_linux:
steps:
- bundle::setup_go_junit_report: { }
- bundle::run_docker_integration_tests:
envs:
- SRC_DIR_IN_GOPATH: $BITRISE_SOURCE_DIR
meta:
bitrise.io:
machine_type_id: elite-xl
stack: linux-docker-android-20.04 # TODO: Docker tests are failing on Ubuntu 22.04
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK, we have a ticket for this in the BE backlog


go test -v ./_tests/integration/ --tags linux_and_mac
test_binary_build_macos:
steps:
- bundle::setup_goreleaser: { }
- bundle::test_binary_build: { }
meta:
bitrise.io:
stack: osx-xcode-16.0.x
machine_type_id: g2.mac.large

if [ "$(uname)" == "Linux" ]; then
go test -v ./_tests/integration/ --tags linux_only
fi
test_binary_build_linux:
steps:
- bundle::setup_goreleaser: { }
- bundle::test_binary_build: { }
meta:
bitrise.io:
machine_type_id: elite-xl
stack: linux-docker-android-22.04

release:
steps:
- trigger-bitrise-workflow@0:
inputs:
- api_token: $CONTROL_CENTER_TRIGGER_KEY
- workflow_id: binary-tool-release
- exported_environment_variable_names: GIT_REPOSITORY_URL
- app_slug: $CONTROL_CENTER_APP_SLUG
meta:
bitrise.io:
machine_type_id: elite-xl
stack: linux-docker-android-22.04

create-release:
description: Creates Linux and Darwin binaries, then publishes a GitHub release
Expand All @@ -59,7 +121,7 @@ workflows:
- AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_PROD
- AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY_PROD
steps:
- script:
- script@1:
title: Fetch GCS bucket credentials
inputs:
- content: |-
Expand All @@ -69,7 +131,7 @@ workflows:
echo "$GCS_BITRISE_CLI_BUCKET_CREDENTIALS" > /tmp/gcs_service_account.json
# Goreleaser expects this env var:
envman add --key GOOGLE_APPLICATION_CREDENTIALS --value /tmp/gcs_service_account.json
- script:
- script@1:
title: Goreleaser (create binaries + publish to GH)
deps:
brew:
Expand All @@ -81,21 +143,6 @@ workflows:

goreleaser release

test-binary-build:
description: Tests the release build process by creating a snapshot release (without publishing)
steps:
- script:
title: Goreleaser (create snapshot binaries)
deps:
brew:
- name: goreleaser
inputs:
- content: |
#!/usr/bin/env bash
set -ex

goreleaser release --snapshot --rm-dist

noop:
title: Noop
description: Empty workflow for quick testing
Expand Down Expand Up @@ -131,3 +178,197 @@ workflows:
- content: |-
set -ex
exit 0

step_bundles:
run_lint:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
- git::https://github.com/bitrise-steplib/steps-check.git:
inputs:
- workflow: lint
- skip_step_yml_validation: "yes"
- deploy-to-bitrise-io@2: { }

run_unit_tests:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
- script@1:
title: Run unit tests and export results
inputs:
- content: |-
#!/usr/bin/env bash
set -ex

# Here we save the original test results and deploy directories and later on we recreate them,
# because during the tests these directories are removed.
ORIG_BITRISE_TEST_RESULT_DIR="${BITRISE_TEST_RESULT_DIR}"
ORIG_BITRISE_DEPLOY_DIR="${BITRISE_DEPLOY_DIR}"

# Setup per OS test name and log file name
if [ "$(uname)" = "Linux" ]; then
test_name_json='{"test-name":"Unit tests (Linux)"}'
test_log_file_name="unit_tests_linux"
else
test_name_json='{"test-name":"Unit tests (macOS)"}'
test_log_file_name="unit_tests_macos"
fi

# Run tests and generate report
go test -v -p 1 ./... 2>&1 | tee "./${test_log_file_name}.log"
mkdir -p "${ORIG_BITRISE_DEPLOY_DIR}"
cp "./${test_log_file_name}.log" "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.log"
go-junit-report -in "./${test_log_file_name}.log" -out "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml"

# Export the junit test results
test_results_dir="${ORIG_BITRISE_TEST_RESULT_DIR}/unit_test_results"
mkdir -p "${test_results_dir}"
cp "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml" "${test_results_dir}/${test_log_file_name}.xml"
echo "${test_name_json}" > "${test_results_dir}/test-info.json"
- deploy-to-bitrise-io@2: { }

run_integration_tests:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
- script@1:
title: Run integration tests and export results
inputs:
- content: |-
#!/usr/bin/env bash
set -exo pipefail

# Here we save the original test results and deploy directories and later on we recreate them,
# because during the tests these directories are removed.
ORIG_BITRISE_TEST_RESULT_DIR="${BITRISE_TEST_RESULT_DIR}"
ORIG_BITRISE_DEPLOY_DIR="${BITRISE_DEPLOY_DIR}"

# Build and setup the current binary
current_bitrise="$(pwd)/_tmp/test_bitrise"
export CGO_ENABLED=0
go build -o "$current_bitrise"

export PR="" PULL_REQUEST_ID=""
export INTEGRATION_TEST_BINARY_PATH="$current_bitrise"
$current_bitrise setup

# Setup per OS test name and log file name
if [ "$(uname)" = "Linux" ]; then
test_name_json='{"test-name":"Integration tests (Linux)"}'
test_log_file_name="integration_tests_linux"
else
test_name_json='{"test-name":"Integration tests (macOS)"}'
test_log_file_name="integration_tests_macos"
fi

# Run tests and generate report
go test -v --tags linux_and_mac ./_tests/integration/... 2>&1 | tee "./${test_log_file_name}.log"

mkdir -p "${ORIG_BITRISE_DEPLOY_DIR}"
cp "./${test_log_file_name}.log" "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.log"

go-junit-report -in "./${test_log_file_name}.log" -out "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml"

# Export the junit test results
test_results_dir="${ORIG_BITRISE_TEST_RESULT_DIR}/integration_test_results"
mkdir -p "${test_results_dir}"
cp "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml" "${test_results_dir}/${test_log_file_name}.xml"
echo "${test_name_json}" > "${test_results_dir}/test-info.json"
- deploy-to-bitrise-io@2: { }

run_docker_integration_tests:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
- script@1:
title: Run integration tests and export results
inputs:
- content: |-
#!/usr/bin/env bash
set -exo pipefail

# Here we save the original test results and deploy directories and later on we recreate them,
# because during the tests these directories are removed.
ORIG_BITRISE_TEST_RESULT_DIR="${BITRISE_TEST_RESULT_DIR}"
ORIG_BITRISE_DEPLOY_DIR="${BITRISE_DEPLOY_DIR}"

# Build and setup the current binary
current_bitrise="$(pwd)/_tmp/test_bitrise"
export CGO_ENABLED=0
go build -o "$current_bitrise"

export PR="" PULL_REQUEST_ID=""
export INTEGRATION_TEST_BINARY_PATH="$current_bitrise"
$current_bitrise setup

# Setup per OS test name and log file name
linux_only_test_name_json='{"test-name":"Linux only integration tests"}'
linux_only_test_log_file_name="linux_only_integration_tests"

# Run tests and generate report
go test -v --tags linux_only ./_tests/integration/... 2>&1 | tee "./${linux_only_test_log_file_name}.log"

mkdir -p "${ORIG_BITRISE_DEPLOY_DIR}"
cp "./${linux_only_test_log_file_name}.log" "${ORIG_BITRISE_DEPLOY_DIR}/${linux_only_test_log_file_name}.log"

go-junit-report -in "./${linux_only_test_log_file_name}.log" -out "${ORIG_BITRISE_DEPLOY_DIR}/${linux_only_test_log_file_name}.xml"

# Export the junit test results
test_results_dir="${ORIG_BITRISE_TEST_RESULT_DIR}/linux_only_integration_test_results"
mkdir -p "${test_results_dir}"
cp "${ORIG_BITRISE_DEPLOY_DIR}/${linux_only_test_log_file_name}.xml" "${test_results_dir}/${linux_only_test_log_file_name}.xml"
echo "${linux_only_test_name_json}" > "${test_results_dir}/test-info.json"

test_binary_build:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
- script@1:
title: Create snapshot binaries
deps:
brew:
- name: goreleaser
inputs:
- content: |
#!/usr/bin/env bash
set -ex

goreleaser release --snapshot --rm-dist
- deploy-to-bitrise-io@2: { }

setup_go_junit_report:
steps:
- script@1:
title: Setup JUnit XML converter
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go install github.com/jstemmer/go-junit-report/v2@latest
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would be good to pin the version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, do we want to pin an exact version? Currently, we pin the major version 2 (github.com/jstemmer/go-junit-report/v2)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that could be enough, but I also don't see any reason not to pin an exact version. A commit hash won't disappear from GitHub (well, it could be force-pushed, but let's hope it never happens)

asdf reshim golang || true

setup_goreleaser:
steps:
- script@1:
inputs:
- content: |-
#!/bin/bash
set -ex

if [ "$(uname)" = "Linux" ]; then
wget -O /tmp/goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v1.19.2/goreleaser_1.19.2_amd64.deb
sudo dpkg -i /tmp/goreleaser.deb
else
go install github.com/goreleaser/goreleaser@latest
fi

meta:
bitrise.io:
machine_type_id: elite-xl
stack: linux-docker-android-22.04