• Stars
    star
    219
  • Rank 175,333 (Top 4 %)
  • Language
    Swift
  • Created about 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Containing all the shared CI logic for WeTransfer repositories

WeTransfer-iOS-CI

Build Status

Containing shared CI logic to quickly set up your repository with:

  • Tests running for each pull request
  • Danger reports for each pull request

Why should I use it?

What's in it for me? Well, quite a lot! With low effort to add it to your project.

  • Integrate SwiftLint to lint source code and tests
  • Integrate Fastlane to run tests for PRs
  • Integrate Danger to automatically improve PR reviews
  • Easily add automated releases based on tag-triggers

Danger features

Following is a list of features which are posted in a comment on PRs based on the submitted files.

  • Warn for big PRs, containing more than 500 lines of code
  • Warn for missing PR description
  • Warn for missing updated tests
  • Show code coverage of PR related files
  • Show any failed tests
  • Show all warnings and errors in the project
  • Show slowest tests

All this is written in Swift and fully tested ๐Ÿš€

Custom linting

These warnings are posted inline inside the PR, helping you to solve them easily.

  • Check for final class usage
  • override methods without adding logic
  • Suggest weak over unowned
  • Suggest // MARK: usage for large files

This is an example comment. Note that WeTransferBot will be replaced by your own bot. More info can be found here: Getting started with Danger.

Adjusting slowests tests

The following environment variables can be used to adjust the slowest tests outcomes:

  • Use SLOW_TESTS_DURATION_THRESHOLD to configure a minimum duration threshold before a slow test shows up. Defaults to 2.
  • Use SLOW_TESTS_LIMIT to configure the limit of slow tests to be shown. Defaults to 3.

How to integrate?

1: Add submodule

Add this repository as a submodule with the correct path Submodules/WeTransfer-iOS-CI:

[submodule "Submodules/WeTransfer-iOS-CI"]
	path = Submodules/WeTransfer-iOS-CI
	url = https://github.com/WeTransfer/WeTransfer-iOS-CI.git

2: Create a fastlane file

Create a fastlane file which executes testing with code coverage enabled. Import the Fastfile from this repo and trigger the test lane.

import "./../Submodules/WeTransfer-iOS-CI/Fastlane/Fastfile"
import "./../Submodules/WeTransfer-iOS-CI/Fastlane/shared_lanes.rb"

desc "Run the tests and prepare for Danger"
lane :test do |options|
  test_project(
    project_path: "YOUR_PROJECT_PATH/",
    project_name: "YOUR_PROJECT_NAME",
    scheme: "YOUR_PROJECT_SCHEME")
end

3: Integrate SwiftLint in your project

Add a run script and use the common used SwiftLint script:

./Submodules/WeTransfer-iOS-CI/SwiftLint/swiftlint.sh

4: Make use of the shared Bitrise.yml workflows

The shared Bitrise.yml files make it really easy to integrate CI into open-source projects. It's been optimized using this blog post for caching and triggers like:

  • Manage gems & brews
  • Cache pulling
  • Run fastlane for testing
  • Run Danger from this repo
  • Cache pushing

How to use this in your Bitrise configuration?

For Danger, you need to set the DANGER_GITHUB_API_TOKEN in your Bitrise secrets.

Make sure your Bitrise.yml looks like this:

trigger_map:
- pull_request_source_branch: "*"
  workflow: wetransfer_pr_testing
workflows:
  wetransfer_pr_testing:
    steps:
    - activate-ssh-key:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone: {}
    - script:
        title: Continue from WeTransfer-iOS-CI repo
        inputs:
        - content: |-
            #!/bin/bash
            set -ex
            bitrise run --config ./Bitrise/testing_bitrise.yml "${BITRISE_TRIGGERED_WORKFLOW_ID}"

Note: Don't change wetransfer_pr_testing as this needs to match the Bitrise.yml file workflow.

5: Add automated releases based on tags

By making use of the Bitrise tag triggered builds we can automate the releases of open-source projects. The automation currently performs the following steps:

  • Automatically fetch the changelog using the ChangelogProducer
  • Create a GitHub release containing the changelog
  • Update and push the podspec
  • Update the Changelog.md with the new changes
  • Create a release branch and open a PR for those changes

How to use this in your Bitrise configuration?

As open-source projects are making use of HTTPS by default we need to force Bitrise to use SSH instead. Therefore, we need to add the SSH key manually to the secret environment variables with the key SSH_RSA_PRIVATE_KEY. You can can read more about this here: How can I generate an SSH key pair?.

We also need to create a environment secret for CocoaPods trunk pushes with the key COCOAPODS_TRUNK_TOKEN. How to do that is explained here: Automated CocoaPod releases with CI.

After all, you're secrets should look as follows:

After that, we need to add a new trigger for tags:

trigger_map:
- pull_request_source_branch: "*"
  workflow: wetransfer_pr_testing
- tag: "*"
  workflow: wetransfer_tag_releasing

And we need to add the new workflow:

wetransfer_tag_releasing:
steps:
- activate-ssh-key:
    run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- script:
    title: Force SSH
    inputs:
    - content: |-
        #!/usr/bin/env bash
        # As we work with submodules, make sure we use SSH for this config so we can push our PR later on.
        # See for more info: https://discuss.bitrise.io/t/git-force-to-use-ssh-url-instead-of-https-for-github-com/4384
        git config --global url."[email protected]:".insteadOf "https://github.com/"
- git-clone: {}
- script:
    title: Continue from WeTransfer-iOS-CI repo
    inputs:
    - content: |-
        #!/bin/bash
        set -ex
        bitrise run --config ./Submodules/WeTransfer-iOS-CI/Bitrise/tag_releasing_bitrise.yml "${BITRISE_TRIGGERED_WORKFLOW_ID}"

After that, you can simply create a new tag and the whole release process will be triggered! ๐Ÿš€

6: App deployment lanes

If you are building an app instead of a framework you can make use of the deployment lanes.

The beta lane takes care of:

  • Generating a changelog based on the GH issues that were solved and PR's that were merged in since the last beta build.
  • Create a draft release in GitHub.
  • Create a new AppStore release candidate and upload it to TestFlight.

The release does the following:

  • Fetch the lates green (approved) release from GitHub.
  • Create a new release branch in GitHub.
  • Create a PR that merges the release branch into the main branch.
  • Create a PR that merges the release branch into develop in order to make sure that develop contains the updated changelog and incremented build number.
  • Create a release build, upload it to TestFlight and submit for review.

These two lanes allow for the following workflow:

  1. Use the beta lane to upload an AppStore Release Candidate to TestFlight.
  2. Once the build went trough QA and has been approved for release mark it as green.
  3. Submit a new build to the App Store using the release lane.

Marking a build as release ready

  • Find the draft release matching the tested TestFlight build number at http://github.com/{organization}/{repo}/releases.
  • Edit the draft and press the green button Publish release.

How to use this in your project?

Import the deployment_lanes.rb from this repo into the Fastfile. If you haven't done so already in step 2 also import the shared_lanes file.

import "./../Submodules/WeTransfer-iOS-CI/Fastlane/deployment_lanes.rb"

Then you need to make sure to authenticate with App Store Connect before running the deployment lanes. This can be done by adding a before_all block, like so:

before_all do |lane, options|
  authenticate
end

Then there is two ways you can start using the deployment lanes. The first one is to create a new lane in the Fastfile from which you call one of the deployment lanes specifying values for all the options. The other option is to use environment variables, for example by using a .env file. In that case the lanes can be called directly without passing any options. An example of a .env file can be found here.

7: Provisioning lanes

The provisioning lanes help you with provisioning related task such as code signing and device management. To use them all you need to do is import provisioning_lanes.rb from this repo into the Fastfile.

Running Bitrise locally

Make sure to have your Bitrise.yml locally inside your repo and then just run bitrise run <workflow_local> after adding the following local testing workflow:

  <workflow_name>_local:
    steps:
    - script:
        title: Setup environment variables
        inputs:
        - content: |-
            #!/bin/bash
            # Change these for your current local session.
            export BITRISE_IO="fake_bitrise"
            export BITRISEIO_GIT_REPOSITORY_OWNER="WeTransfer"                                                                                       
            export BITRISEIO_GIT_REPOSITORY_SLUG="WeTransfer-iOS-SDK"                                                                                
            export BITRISE_PULL_REQUEST=452                                                                                                          

            bitrise run <workflow_name>

Doing so allows you to run Bitrise workflows locally which will even update the Danger messages in GitHub itself. It kind of mimics this Bitrise representation using env variables.

Bitrise Key-Based caching

Key-based caching uses checksums. To test out a checksum locally, use find . -print | grep -i */Package.resolved. For example, that could result in:

- key: spm-cache-{{ checksum "Package.resolved" "*.xcodeproj/**/Package.resolved" "WeTransferPRLinter/Package.resolved" }}

Decompress caches

If you want to decompress a tzst cache file after downloading it from Bitrise, you can use the following command:

% tar -xvf /path/to/cache-20221110-112409.tzst 

Danger Binary Updating

  • See danger/swift#476
  • Fork https://github.com/danger/swift
  • Update Danger's Package.swift to Swift 5.7 and switch isDevelop to false
  • Run swift build --configuration release --arch arm64 --arch x86_64
  • Copy the file from .build/apple/Products/Release/danger-swift

License

WeTransfer-iOS-CI is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

WeScan

Document Scanning Made Easy for iOS
Swift
2,756
star
2

Mocker

Mock Alamofire and URLSession requests without touching your code implementation
Swift
1,051
star
3

Diagnostics

Allow users to easily share Diagnostics with your support team to improve the flow of fixing bugs.
Swift
899
star
4

UINotifications

Present custom in-app notifications easily in Swift
Swift
395
star
5

zip_tricks

Compact ZIP file writing/reading for Ruby, for streaming applications
Ruby
351
star
6

GitBuddy

Your buddy in managing and maintaining GitHub repositories, and releases. Automatically generate changelogs from issues and merged pull-requests.
Swift
242
star
7

prorate

Redis-based rate limiter (with a leaky bucket implementation in Lua)
Ruby
85
star
8

wt_activerecord_index_spy

A gem to spy queries running with Active Record and report missing indexes
Ruby
77
star
9

format_parser

file metadata parsing, done cheap
Ruby
60
star
10

wt-js-sdk

A JavaScript SDK for WeTransfer's Public API
JavaScript
46
star
11

WeTransfer-Swift-SDK

A Swift SDK for WeTransferโ€™s public API
Swift
39
star
12

Sketch-Plugin

Plugin to share artboards directly via WeTransfer. Share the link easily with your colleagues and friends.
Objective-C
38
star
13

sqewer

SQS queue processor engine
Ruby
29
star
14

cr_zip_tricks

Alternate ZIP writer for Crystal, ported from zip_tricks for Ruby
Crystal
25
star
15

wt_s3_signer

Fast S3 key urls signing
Ruby
22
star
16

image_vise

Image processing proxy that works via signed URLs
Ruby
20
star
17

ghost_adapter

Run ActiveRecord migrations through gh-ost
Ruby
18
star
18

concorde.js

A sexy pinnacle of engineering thatโ€™s nonetheless incredibly inefficient and expensive and goes out of business because it canโ€™t find enough use. It also provides some tools to deal with the browser.
JavaScript
17
star
19

fast_send

Send very large HTTP responses via file buffers
Ruby
16
star
20

apiculture

Honey-tasting REST API toolkit for Sinatra
Ruby
12
star
21

WeScanAndroid

The Android Implementation of WeScan https://github.com/wetransfer/wescan
11
star
22

wetransfer_ruby_sdk

A Ruby SDK for WeTransfer's Public API
Ruby
11
star
23

measurometer

Minimum viable API for โฑ๐Ÿ“ˆ in ๐Ÿ’Ž libraries
Ruby
10
star
24

richurls

Service which enriches URLs fast and cheap
Ruby
10
star
25

interval_response

Serve partial (Range) HTTP responses from ๐Ÿ’Ž applications
Ruby
9
star
26

activerecord_autoreplica

Simple read replica proxy for ActiveRecord
Ruby
7
star
27

wt-api-docs

Official documentation for WeTransfer's Public API
JavaScript
7
star
28

product-engineering-career-framework

This repo holds discussion and the permalink to WeTransfer's internal Product Engineering Career Framework.
7
star
29

hash_tools

Do useful things to Ruby Hashes, without monkey-patches
Ruby
5
star
30

rational_choice

A fuzzy logic gate
Ruby
4
star
31

Xperiments

Simple A/B testing tool. Includes CMS and an experimentation engine.
JavaScript
4
star
32

Danger

Contains our global Danger file.
Ruby
3
star
33

Tatsi

A drop-in replacement for UIImagePickerController with the ability to select multiple images and/or videos
Swift
3
star
34

eslint-config-wetransfer

ESLint shareable config used for WeTransfer JS projects.
JavaScript
3
star
35

wetransfer_style

At WeTransfer we code in style. This is our coding style for Ruby development.
Ruby
3
star
36

runaway

Controls child process execution, with hard limits on maximum runtime and heartbeat timings
Ruby
2
star
37

very_tiny_state_machine

For when you need it even smaller than you think you do
Ruby
2
star
38

megabytes

Tiny byte size formatter
Ruby
1
star
39

Actions-Experiment

A Repo to experiment with github actions to build previews for the frontend.
JavaScript
1
star
40

strict_request_uri

Truncate and cleanup URLs with junk in Rack
Ruby
1
star
41

tdd-workshop

Repo to host the code for the TDD workshop
Kotlin
1
star
42

departure

WeTransfer's fork of departurerb/departure, to accelerate Rails 5.2 support. See the link for the original repo:
Ruby
1
star
43

sanitize_user_agent_header

Ensure User-Agent gets correctly UTF-8 encoded
Ruby
1
star
44

ks

Keyword-initialized Structs
Ruby
1
star
45

format_parser_pdf

file metadata parsing, for PDF
Ruby
1
star
46

EmbedExamples

Examples on how to use WeTransfer Embed
Ruby
1
star
47

simple_compress

GZIP compression to and from a String
Ruby
1
star