Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abematviosbot committed May 22, 2023
0 parents commit 7635f8d
Show file tree
Hide file tree
Showing 229 changed files with 10,854 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_CLEAN: "true"
BUNDLE_RETRY: "5"
BUNDLE_JOBS: "20"
256 changes: 256 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
# https://circleci.com/docs/2.0/configuration-reference
# https://circleci.com/docs/2.0/testing-ios

version: 2.1

executors:
default: &default
macos:
xcode: 14.1
environment:
HOMEBREW_NO_AUTO_UPDATE: 1
FASTLANE_SKIP_UPDATE_CHECK: 1
SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA: "true"

parameters:
run_test:
default: true
type: boolean

commands:
shallow_checkout:
description: Shallow checkout and LFS caching
parameters:
depth:
type: integer
default: 1
steps:
- run:
name: Shallow checkout
command: |
# 標準のcheckoutステップではdepth指定ができないため、直接実行する
set -euo pipefail
# https://discuss.circleci.com/t/17007/5
CIRCLE_WORKING_DIRECTORY="${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}"
mkdir -p $HOME/.ssh
ssh-keyscan -H github.com >> $HOME/.ssh/known_hosts
git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"
export GIT_LFS_SKIP_SMUDGE=1
if [ -n "${CIRCLE_TAG:-}" ]; then
git clone \
--branch="$CIRCLE_TAG" \
--depth=<<parameters.depth>> \
"$CIRCLE_REPOSITORY_URL" "$CIRCLE_WORKING_DIRECTORY"
elif [ -n "${CIRCLE_BRANCH:-}" ]; then
git clone \
--branch="$CIRCLE_BRANCH" \
--depth=<<parameters.depth>> \
"$CIRCLE_REPOSITORY_URL" "$CIRCLE_WORKING_DIRECTORY"
else
git clone \
--depth=<<parameters.depth>> \
"$CIRCLE_REPOSITORY_URL" "$CIRCLE_WORKING_DIRECTORY"
fi
git reset --hard "$CIRCLE_SHA1"
git submodule update --init --recursive --recommend-shallow --depth=<<parameters.depth>>
lfs_pull:
steps:
- run:
name: Write out a list of LFS-managed files for caching
command: git lfs ls-files -l | cut -d' ' -f1 | sort > .assets-id
- restore_cache:
name: Restoring LFS cache
keys:
- v1-lfs-{{ checksum ".assets-id" }}
- v1-lfs-
- run:
name: Show LFS status
command: git lfs ls-files -d
- run: git lfs pull
- run: git lfs prune
- save_cache:
name: Saving LFS cache
paths: [./.git/lfs]
key: v1-lfs-{{ checksum ".assets-id" }}

prepare_ruby:
steps:
- run:
name: Specify Ruby version
command: |
if ! command -v chruby >/dev/null; then
echo "chruby not found; skipped"
exit 0
fi
RUBY_VERSION=$(cat .ruby-version | sed -E 's/^([0-9]+\.[0-9]+)(\.[0-9]+)?$/\1/g')
chruby $RUBY_VERSION
echo $'\n'"chruby $RUBY_VERSION" >> ~/.bash_profile
- run:
name: Install gems
command: |
touch Gemfile # キャッシュがある場合でも実行させる
make install-gems
prepare_netrc:
steps:
- run:
name: Set Username and Personal Token to netrc
command: |
cat \<<- EOS >> $HOME/.netrc
machine api.github.com
login abematv-native
password $GITHUB_ACCESS_TOKEN
EOS
chmod 600 $HOME/.netrc
start_simulator:
parameters:
device:
type: string
steps:
- run:
name: Starting iPhone Simulator
command: |
xcrun simctl boot "<<parameters.device>>"
export DEVICE="<<parameters.device>>"
restore_cache_rubygem:
steps:
- restore_cache:
name: Restoring RubyGems cache
keys:
- v2-rubygems-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- v2-rubygems-{{ arch }}-{{ .Branch }}-
- v2-rubygems-{{ arch }}-
save_cache_rubygem:
steps:
- save_cache:
name: Saving RubyGems cache
paths: [./vendor/bundle]
key: v2-rubygems-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}

restore_cache_mint:
steps:
- restore_cache:
name: Restoring Mint cache
keys:
# Mintは複数バージョン共存できるのでブランチとチェックサムを無視する
- v2-mint-
save_cache_mint:
steps:
- save_cache:
name: Saving Mint cache
paths: [./.mint]
key: v2-mint-{{ .Branch }}-{{ checksum "Mintfile" }}

store_xcresult_artifacts:
steps:
- run:
name: Archiving xcresults
when: always
command: tar czf build/xcresults{.tar.gz,}
- store_artifacts: { path: build/xcresults.tar.gz }

bootstrap:
steps:
- lfs_pull

- restore_cache_rubygem
- restore_cache_mint

- prepare_ruby
- prepare_netrc

- run: make bootstrap
- run: make mint-xcbeautify # .mint/配下に入れる

- save_cache_rubygem
- save_cache_mint

jobs:
build:
executor: default

steps:
- start_simulator:
device: "iPhone 14"

- shallow_checkout
- bootstrap

- run:
name: Check project integration for CocoaPods
command: bundle exec fastlane run check_cocoapods_templates

- run: make --keep-going build | tee build.log | make test-output-formatter
- store_artifacts: { path: build.log }

- store_xcresult_artifacts

- when: # master以外のブランチでのみDangerを実行
condition: { not: { equal: [<<pipeline.git.branch>>, master] } }
steps:
# WORKAROUND: shallow cloneしているとDangerがfetchしなおしてしまうため、
# base commitまでの履歴だけを取得する
- run:
name: Fetch additional commits
when: always
command: >
GITHUB_API_TOKEN=$GITHUB_ACCESS_TOKEN
scripts/ci/git-deepen.sh
-p $CIRCLE_PULL_REQUEST
-r $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
- run:
name: Danger
when: always
command: >
DANGER_GITHUB_API_TOKEN=$GITHUB_ACCESS_TOKEN
bundle exec danger
test:
executor: default

steps:
- start_simulator:
device: "iPhone 14"

- shallow_checkout
- bootstrap

- run:
name: Check project integration for CocoaPods
command: bundle exec fastlane run check_cocoapods_templates

- run: make --keep-going test | tee test.log | make test-output-formatter
- store_artifacts: { path: test.log }

- store_xcresult_artifacts

- when: # master以外のブランチでのみDangerを実行
condition: { not: { equal: [<<pipeline.git.branch>>, master] } }
steps:
# WORKAROUND: shallow cloneしているとDangerがfetchしなおしてしまうため、
# base commitまでの履歴だけを取得する
- run:
name: Fetch additional commits
when: always
command: >
scripts/ci/git-deepen.sh
-p $CIRCLE_PULL_REQUEST
-r $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
- run:
name: Danger
when: always
command: >
DANGER_GITHUB_API_TOKEN=$GITHUB_ACCESS_TOKEN
bundle exec danger
workflows:
test:
when: <<pipeline.parameters.run_test>>
jobs:
- build:
filters:
branches: { ignore: /.*-master/ }
- test:
filters:
branches: { only: /.*-master/ }
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab
tab_width = 2
41 changes: 41 additions & 0 deletions .github/workflows/publish-answers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Answers

on:
push:
branches: [public-answer]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Set Username and Authentication
run: |
git config --global user.name abematviosbot
git config --global user.email [email protected]
cat <<- EOS >> $HOME/.netrc
machine github.com
login abematviosbot
password ${{ secrets.BOT_GITHUB_TOKEN }}
EOS
chmod 600 $HOME/.netrc
- name: Publish Answers
run: |
set -eux
git remote add public https://github.com/abema/abema-ios-tutorial-public
git fetch public
COMMITS=$(git log -n $NUMBER_OF_ANSWERS --pretty=%H --reverse)
git checkout -b answer-base public/master
INDEX=0
for COMMIT in $COMMITS; do
INDEX=$(expr $INDEX + 1)
git checkout -b answer-$INDEX
git cherry-pick $COMMIT
git push -f public HEAD
done
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
NUMBER_OF_ANSWERS: 4
34 changes: 34 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
push:
branches: [public]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Set Username and Authentication
run: |
git config --global user.name abematviosbot
git config --global user.email [email protected]
cat <<- EOS >> $HOME/.netrc
machine github.com
login abematviosbot
password ${{ secrets.BOT_GITHUB_TOKEN }}
EOS
chmod 600 $HOME/.netrc
- name: Publish
run: |
rm -rf .git
git init
git add .
git commit -m 'Initial commit'
git remote add public https://github.com/abema/abema-ios-tutorial-public
git push public master --force
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Mac OSX
#
.DS_Store

# Xcode
#
xcuserdata
DerivedData
*.xcodeproj

# CocoaPods
/Pods/*
!/Pods/Target Support Files
/Pods/Target Support Files/*
!/Pods/Target Support Files/Pods-*

# Bundler / Ruby Gem
vendor/

# Mint
.mint
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.3
Loading

0 comments on commit 7635f8d

Please sign in to comment.