Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into andy/firebird-issue-81
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Sep 10, 2024
2 parents 7e68496 + 5ba1331 commit b88bf41
Show file tree
Hide file tree
Showing 128 changed files with 3,775 additions and 868 deletions.
14 changes: 14 additions & 0 deletions .buildkite/commands/checkout-release-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -eu

# We expect BUILDKITE_RELEASE_VERSION to be as an environment variable, e.g. by the automation that triggers the build on Buildkite.
# It must use the `BUILDKITE_` prefix to be passed to the agent due to how `hostmgr` works, in case this runs on a Mac agents.
if [[ -z "${BUILDKITE_RELEASE_VERSION}" ]]; then
echo "BUILDKITE_RELEASE_VERSION is not set."
exit 1
fi

# Buildkite, by default, checks out a specific commit.
# For many release actions, we need to be on a release branch instead.
BRANCH_NAME="release/${BUILDKITE_RELEASE_VERSION}"
git fetch origin "$BRANCH_NAME"
git checkout "$BRANCH_NAME"
24 changes: 24 additions & 0 deletions .buildkite/commands/release-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -eu

echo "--- :rubygems: Setting up Gems"
install_gems

echo "--- :closed_lock_with_key: Installing Secrets"
bundle exec fastlane run configure_apply

echo "--- :hammer_and_wrench: Building app"
bundle exec fastlane build_for_distribution

echo "--- :computer: Use deterministic APK name for next steps"

OUTPUT_DIR="build"
if [ "$(find "$OUTPUT_DIR/*.apk" | wc -l)" -gt 1 ]; then
echo "Found more than one APK in $OUTPUT_DIR."
exit 1
fi

ORIGINAL_APK_PATH=$(ls -1 "$OUTPUT_DIR/*.apk")

set -x
mv "$ORIGINAL_APK_PATH" $OUTPUT_DIR/simplenote.apk
set +x
17 changes: 17 additions & 0 deletions .buildkite/commands/release-create-on-github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -eu

echo "--- :arrow_down: Downloading Artifacts"
ARTIFACT_PATH='build/simplenote.apk' # Must be the same as release-build.sh
STEP=build
buildkite-agent artifact download "$ARTIFACT_PATH" . --step $STEP

echo "--- :rubygems: Setting up Gems"
install_gems

echo "--- :closed_lock_with_key: Installing Secrets"
bundle exec fastlane run configure_apply

echo "--- :android: Upload to Play Store"
bundle exec fastlane create_release_on_github \
apk_path:"$ARTIFACT_PATH" \
"beta:${1:-true}" # use first call param, default to true for safety
17 changes: 17 additions & 0 deletions .buildkite/commands/release-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -eu

echo "--- :arrow_down: Downloading Artifacts"
ARTIFACT_PATH='build/simplenote.apk' # Must be the same as release-build.sh
STEP=build
buildkite-agent artifact download "$ARTIFACT_PATH" . --step $STEP

echo "--- :rubygems: Setting up Gems"
install_gems

echo "--- :closed_lock_with_key: Installing Secrets"
bundle exec fastlane run configure_apply

echo "--- :android: Upload to Play Store"
bundle exec fastlane upload_build_to_play_store \
apk_path:"$ARTIFACT_PATH/simplenote.apk" \
"beta:${1:-true}" # use first call param, default to true for safety
54 changes: 35 additions & 19 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,50 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# Nodes with values to reuse in the pipeline.
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.13.0

agents:
queue: "android"
queue: android

# This is the default pipeline – it will build and test the app
steps:
- label: "Gradle Wrapper Validation"
command: |
validate_gradle_wrapper
plugins: *common_plugins
- label: ":gradle: Gradle Wrapper Validation"
command: validate_gradle_wrapper
plugins: [$CI_TOOLKIT_PLUGIN]
notify:
- github_commit_status:
context: Gradle Wrapper Validation

# Wait for Gradle Wrapper to be validated before running any other jobs
- wait

- label: "🛠 Build and Test"
- label: ":hammer_and_pick: Build and Test"
command: ./gradlew --stacktrace testRelease
plugins: *common_plugins
plugins: [$CI_TOOLKIT_PLUGIN]
notify:
- github_commit_status:
context: Build and Test

- label: ":radioactive_sign: Danger - PR Check"
command: danger
key: danger
if: "build.pull_request.id != null"
retry:
manual:
permit_on_passed: true
agents:
queue: linter
notify:
- github_commit_status:
context: Danger - PR Check

- label: "🔬 Lint"
- label: ":microscope: Lint"
command: ./gradlew --stacktrace lintRelease
plugins: *common_plugins
plugins: [$CI_TOOLKIT_PLUGIN]
notify:
- github_commit_status:
context: Lint

- label: "🛠 Prototype Build"
- label: ":hammer_and_pick: Prototype Build"
command: .buildkite/commands/build-prototype.sh
plugins: *common_plugins
plugins: [$CI_TOOLKIT_PLUGIN]
if: "build.pull_request.id != null || build.pull_request.draft"
notify:
- github_commit_status:
context: Prototype Build
41 changes: 41 additions & 0 deletions .buildkite/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# This pipeline is meant to be run via the Buildkite API, and is only used for release builds

agents:
queue: android

steps:
- label: ":gradle: Gradle Wrapper Validation"
command: validate_gradle_wrapper
priority: 1
plugins: [$CI_TOOLKIT_PLUGIN]

- wait

- label: ":hammer_and_pick: Build"
key: build
command: .buildkite/commands/release-build.sh
priority: 1
plugins: [$CI_TOOLKIT_PLUGIN]
artifact_paths: ["build/*.apk"]
notify:
- slack: "#build-and-ship"

- label: ":android: Upload to Play Store"
depends_on: build
key: upload_play_store
command: .buildkite/commands/release-upload.sh $BETA_RELEASE
priority: 1
plugins: [$CI_TOOLKIT_PLUGIN]
notify:
- slack: "#build-and-ship"

- label: ":github: Create GitHub relaese"
depends_on: upload_play_store
command: .buildkite/commands/release-create-on-github.sh $BETA_RELEASE
priority: 1
plugins: [$CI_TOOLKIT_PLUGIN]
notify:
- slack: "#build-and-ship"
32 changes: 32 additions & 0 deletions .buildkite/release-pipelines/complete-code-freeze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# Variables used in this pipeline are defined in `shared-pipeline-vars`, which is `source`'d before calling `buildkite-agent pipeline upload`

agents:
queue: tumblr-metal

steps:
- label: Complete Code Freeze
key: complete_code_freeze
plugins: [$CI_TOOLKIT_PLUGIN]
command: |
echo '--- :robot_face: Use bot for Git operations'
source use-bot-for-git wpmobilebot
echo '--- :git: Checkout release branch'
.buildkite/commands/checkout-release-branch.sh
echo '--- :ruby: Set up Ruby Tools'
install_gems
echo '--- :closed_lock_with_key: Access secrets'
bundle exec fastlane run configure_apply
echo '--- :shipit: Complete code freeze'
bundle exec fastlane complete_code_freeze skip_confirm:true
retry:
manual:
# If failed, we prefer retrying via ReleaseV2 rather than Buildkite.
# Rationale: ReleaseV2 is the source of truth for the process and track links to the various builds.
allowed: false
25 changes: 25 additions & 0 deletions .buildkite/release-pipelines/start-code-freeze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# Variables used in this pipeline are defined in `shared-pipeline-vars`, which is `source`'d before calling `buildkite-agent pipeline upload`

steps:
- label: Start Code Freeze
plugins:
- $CI_TOOLKIT_PLUGIN
agents:
queue: tumblr-metal
command: |
echo '--- :robot_face: Use bot for Git operations'
source use-bot-for-git wpmobilebot
echo '--- :ruby: Setup Ruby Tools'
install_gems
echo '--- :shipit: Start code freeze'
bundle exec fastlane start_code_freeze skip_confirm:true
retry:
manual:
# If failed, we prefer retrying via ReleaseV2 rather than Buildkite.
# Rationale: ReleaseV2 is the source of truth for the process and track links to the various builds.
allowed: false
8 changes: 8 additions & 0 deletions .buildkite/shared-pipeline-vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it.

export CI_TOOLKIT_PLUGIN_VERSION="3.5.1"

export CI_TOOLKIT_PLUGIN="automattic/a8c-ci-toolkit#$CI_TOOLKIT_PLUGIN_VERSION"
16 changes: 10 additions & 6 deletions .github/workflows/run-danger.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: ☢️ Danger
name: ☢️ Trigger Danger On Buildkite

on:
pull_request:
types: [opened, reopened, ready_for_review, synchronize, edited, labeled, unlabeled, milestoned, demilestoned]
types: [labeled, unlabeled, milestoned, demilestoned, ready_for_review]

jobs:
dangermattic:
# runs on draft PRs only for opened / synchronize events
if: ${{ (github.event.pull_request.draft == false) || (github.event.pull_request.draft == true && contains(fromJSON('["opened", "synchronize"]'), github.event.action)) }}
uses: Automattic/dangermattic/.github/workflows/[email protected]
if: ${{ (github.event.pull_request.draft == false) }}
uses: Automattic/dangermattic/.github/workflows/[email protected]
with:
org-slug: "automattic"
pipeline-slug: "simplenote-android"
retry-step-key: "danger"
build-commit-sha: "${{ github.event.pull_request.head.sha }}"
secrets:
github-token: ${{ secrets.DANGERMATTIC_GITHUB_TOKEN }}
buildkite-api-token: ${{ secrets.TRIGGER_BK_BUILD_TOKEN }}
12 changes: 8 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ AllCops:
SuggestExtensions:
rubocop-rake: false

Metrics/MethodLength:
Max: 30

Layout/LineLength:
Max: 180

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Metrics/MethodLength:
Max: 30

Metrics/BlockLength:
Exclude:
Exclude: &fastlane
- fastlane/Fastfile
- fastlane/lanes/*.rb

Style/HashSyntax:
EnforcedShorthandSyntax: never
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ source 'https://rubygems.org'

gem 'danger-dangermattic', '~> 1.0'
gem 'fastlane', '~> 2.219'
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 9.1'
# This comment avoids typing to switch to a development version for testing.
#
# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref: ''
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 12.0'
Loading

0 comments on commit b88bf41

Please sign in to comment.