From f1d302f849ad4d76fbec525c96680ed03a64f44e Mon Sep 17 00:00:00 2001 From: Adriaan Duz Date: Tue, 10 Jan 2023 09:46:37 +0100 Subject: [PATCH 1/7] Create objective-c-xcode.yml --- .github/workflows/objective-c-xcode.yml | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/objective-c-xcode.yml diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml new file mode 100644 index 0000000..68b8c8f --- /dev/null +++ b/.github/workflows/objective-c-xcode.yml @@ -0,0 +1,30 @@ +name: Xcode - Build and Analyze + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + name: Build and analyse default scheme using xcodebuild command + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set Default Scheme + run: | + scheme_list=$(xcodebuild -list -json | tr -d "\n") + default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") + echo $default | cat >default + echo Using default scheme: $default + - name: Build + env: + scheme: ${{ 'default' }} + run: | + if [ $scheme = default ]; then scheme=$(cat default); fi + if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi + file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` + xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} From 5ba8c2d8024b3bd1e15f0cd103a8fddf2364f079 Mon Sep 17 00:00:00 2001 From: "SuperSimple.io" Date: Mon, 16 Jan 2023 22:47:37 +0100 Subject: [PATCH 2/7] Update build script and GH Action --- .github/workflows/objective-c-xcode.yml | 38 +++++++++++++++---------- .ruby-version | 2 +- script/bootstrap | 14 +++++---- script/build | 2 +- script/cibuild | 2 +- script/lint | 2 +- script/server | 13 --------- script/setup | 2 +- script/test | 2 +- script/update | 2 +- 10 files changed, 39 insertions(+), 40 deletions(-) delete mode 100755 script/server diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml index 68b8c8f..9da5044 100644 --- a/.github/workflows/objective-c-xcode.yml +++ b/.github/workflows/objective-c-xcode.yml @@ -2,9 +2,16 @@ name: Xcode - Build and Analyze on: push: - branches: [ "master" ] + branches: + - master pull_request: - branches: [ "master" ] + branches: + - master + +env: + LC_CTYPE: en_US.UTF-8 + LANG: en_US.UTF-8 + LANGUAGE: en_US.UTF-8 jobs: build: @@ -12,19 +19,20 @@ jobs: runs-on: macos-latest steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable - name: Checkout uses: actions/checkout@v3 - - name: Set Default Scheme - run: | - scheme_list=$(xcodebuild -list -json | tr -d "\n") - default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") - echo $default | cat >default - echo Using default scheme: $default - - name: Build - env: - scheme: ${{ 'default' }} + - name: Setup + run: make setup + - name: Danger run: | - if [ $scheme = default ]; then scheme=$(cat default); fi - if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi - file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` - xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]} + bundle exec danger + bash <(curl -s https://codecov.io/bash) -J 'DataKit' + - name: Test code Coverage + run: make cibuild FL_LANE=code_coverage FASTLANE_ENV=default + - name: Build iOS + run: make cibuild FASTLANE_ENV=ios13_xcode11 + - name: Build macOS + run: make cibuild FASTLANE_ENV=osx15 diff --git a/.ruby-version b/.ruby-version index e70b452..ec1cf33 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.0 +2.6.3 diff --git a/script/bootstrap b/script/bootstrap index 04cab2d..400f3c5 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,9 +1,9 @@ -#!/bin/sh +#!/usr/bin/env bash # script/bootstrap: Resolve all dependencies that the application requires to # run. -set -ev +set -eo pipefail cd "$(dirname "$0")/.." @@ -33,9 +33,13 @@ fi # fi if [ -f "Gemfile" ]; then + hash bundle 2>/dev/null || { + echo "==> Installing gem bundler 2.1.4…" + gem install bundler -v 2.1.4 --no-document --quiet + } echo "==> Installing gem dependencies…" - gem install bundler -v 2.0.1 --no-document --quiet - bundle check --path vendor/gems >/dev/null 2>&1 || { - bundle install --path vendor/gems --quiet --without production + bundle config set path 'vendor/gems' + bundle check >/dev/null 2>&1 || { + bundle install --quiet } fi diff --git a/script/build b/script/build index 4d22fab..aa86746 100755 --- a/script/build +++ b/script/build @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # script/build: Build the application.s diff --git a/script/cibuild b/script/cibuild index f4d2019..725f30d 100755 --- a/script/cibuild +++ b/script/cibuild @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # script/cibuild: Setup environment for CI to run tests. This is primarily # designed to run on the continuous integration server. diff --git a/script/lint b/script/lint index fd12661..d3fa4dd 100755 --- a/script/lint +++ b/script/lint @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # script/lint: Run lint for application. diff --git a/script/server b/script/server deleted file mode 100755 index 7325252..0000000 --- a/script/server +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# script/server: Launch the application and any extra required processes -# locally. - -set -ev - -cd "$(dirname "$0")/.." - -# ensure everything in the app is up to date. -script/update - -echo "Server is not applicable for this project" diff --git a/script/setup b/script/setup index b32b70d..e480a8d 100755 --- a/script/setup +++ b/script/setup @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # script/setup: Set up application for the first time after cloning, or set it # back to the initial first unused state. diff --git a/script/test b/script/test index 5a6e6b2..d713202 100755 --- a/script/test +++ b/script/test @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # script/test: Run test suite for application. Optionally pass in a path to an # individual test file to run a single test. diff --git a/script/update b/script/update index 03f6baa..7d3cba7 100755 --- a/script/update +++ b/script/update @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # script/update: Update application to run for its current checkout. From d3d0099789f77664db95847f43f893d63e6d2d9b Mon Sep 17 00:00:00 2001 From: "SuperSimple.io" Date: Mon, 16 Jan 2023 22:52:08 +0100 Subject: [PATCH 3/7] Ruby version 2.6.3 --- .github/workflows/objective-c-xcode.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml index 9da5044..a681439 100644 --- a/.github/workflows/objective-c-xcode.yml +++ b/.github/workflows/objective-c-xcode.yml @@ -22,6 +22,9 @@ jobs: - uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: latest-stable + - uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6.3' - name: Checkout uses: actions/checkout@v3 - name: Setup From e5224358baf4b1ae2630a01a3f2877282f4b9e32 Mon Sep 17 00:00:00 2001 From: "SuperSimple.io" Date: Mon, 16 Jan 2023 23:13:36 +0100 Subject: [PATCH 4/7] Up ruby 2.7.7 --- .github/workflows/objective-c-xcode.yml | 8 ++++---- .ruby-version | 2 +- Gemfile | 2 +- Gemfile.lock | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml index a681439..ddf926d 100644 --- a/.github/workflows/objective-c-xcode.yml +++ b/.github/workflows/objective-c-xcode.yml @@ -19,14 +19,14 @@ jobs: runs-on: macos-latest steps: + - name: Checkout + uses: actions/checkout@v3 - uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: latest-stable - - uses: actions/setup-ruby@v1 + - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.6.3' - - name: Checkout - uses: actions/checkout@v3 + bundler-cache: true - name: Setup run: make setup - name: Danger diff --git a/.ruby-version b/.ruby-version index ec1cf33..1f7da99 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.3 +2.7.7 diff --git a/Gemfile b/Gemfile index 9068f2b..6223630 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -ruby "~>2.6" +ruby "~>2.7" gem "fastlane", "~>2.206" gem "danger", "~>8.4" diff --git a/Gemfile.lock b/Gemfile.lock index 3a011fe..dcd14e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -348,7 +348,7 @@ DEPENDENCIES xcodeproj (~> 1.21) RUBY VERSION - ruby 2.6.5p114 + ruby 2.7.7p221 BUNDLED WITH 1.17.3 From ca58a62c938da58449d4299c7dfcb763ff8d3a73 Mon Sep 17 00:00:00 2001 From: "SuperSimple.io" Date: Mon, 16 Jan 2023 23:42:28 +0100 Subject: [PATCH 5/7] Add DANGER_GITHUB_API_TOKEN --- .github/workflows/objective-c-xcode.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml index ddf926d..556cf4b 100644 --- a/.github/workflows/objective-c-xcode.yml +++ b/.github/workflows/objective-c-xcode.yml @@ -30,6 +30,8 @@ jobs: - name: Setup run: make setup - name: Danger + env: + DANGER_GITHUB_API_TOKEN: {{ secrets.DANGER_GITHUB_API_TOKEN }} run: | bundle exec danger bash <(curl -s https://codecov.io/bash) -J 'DataKit' From a5f1dba950f8015f5e6103d2980e9e860f5659fc Mon Sep 17 00:00:00 2001 From: "SuperSimple.io" Date: Mon, 16 Jan 2023 23:48:26 +0100 Subject: [PATCH 6/7] Separate job for Danger --- .github/workflows/objective-c-xcode.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml index 556cf4b..e246ae5 100644 --- a/.github/workflows/objective-c-xcode.yml +++ b/.github/workflows/objective-c-xcode.yml @@ -14,10 +14,23 @@ env: LANGUAGE: en_US.UTF-8 jobs: + danger: + name: Check Danger + runs-on: ubuntu-latest + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Check + run: bundle exec danger + build: name: Build and analyse default scheme using xcodebuild command runs-on: macos-latest - steps: - name: Checkout uses: actions/checkout@v3 @@ -29,14 +42,10 @@ jobs: bundler-cache: true - name: Setup run: make setup - - name: Danger - env: - DANGER_GITHUB_API_TOKEN: {{ secrets.DANGER_GITHUB_API_TOKEN }} + - name: Test code Coverage run: | - bundle exec danger + make cibuild FL_LANE=code_coverage FASTLANE_ENV=default bash <(curl -s https://codecov.io/bash) -J 'DataKit' - - name: Test code Coverage - run: make cibuild FL_LANE=code_coverage FASTLANE_ENV=default - name: Build iOS run: make cibuild FASTLANE_ENV=ios13_xcode11 - name: Build macOS From 6c3e71a125fc25aff71806d94116a65130898293 Mon Sep 17 00:00:00 2001 From: "SuperSimple.io" Date: Mon, 16 Jan 2023 23:56:33 +0100 Subject: [PATCH 7/7] Cancel previous --- .github/workflows/objective-c-xcode.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/objective-c-xcode.yml b/.github/workflows/objective-c-xcode.yml index e246ae5..c41acab 100644 --- a/.github/workflows/objective-c-xcode.yml +++ b/.github/workflows/objective-c-xcode.yml @@ -14,11 +14,23 @@ env: LANGUAGE: en_US.UTF-8 jobs: + cancel-previous: + name: Cancel Previous + permissions: + contents: read + actions: write + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Build + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} danger: name: Check Danger runs-on: ubuntu-latest + needs: cancel-previous env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + DANGER_GITHUB_BEARER_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} steps: - name: Checkout uses: actions/checkout@v3 @@ -31,6 +43,7 @@ jobs: build: name: Build and analyse default scheme using xcodebuild command runs-on: macos-latest + needs: cancel-previous steps: - name: Checkout uses: actions/checkout@v3