Skip to content

Commit

Permalink
👷 :: CI workflows 수정
Browse files Browse the repository at this point in the history
- 브랜치 이름에 따른 skip 조건 제거, CI 실행 시 `tuist test` 실행
  • Loading branch information
baekteun committed Feb 1, 2024
1 parent ab6a81f commit 11916ac
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 109 deletions.
155 changes: 46 additions & 109 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,131 +1,68 @@
name: CI

on:
pull_request:
push:
branches:
- develop
- master
pull_request:
branches:
- "*"

env:
CACHED_DEPENDENCY_PATHS: ${{ github.workspace }}/Tuist/Dependencies

jobs:
prepare-ci:
name: Prepare CI
runs-on: macOS-latest
outputs:
NAME: ${{ steps.get_name.outputs.NAME }}
CI-NEEDED: ${{ steps.check_ci_needed.outputs.CI-NEEDED }}
WROKING-PATH: ${{ steps.get_working_directory.outputs.PATH }}
TESTS-EXISTENCE: ${{ steps.check_tests_existence.outputs.files_exists }}
steps:
- uses: actions/checkout@v1

- name: Get Branch Name
uses: tj-actions/branch-names@v6.2
id: branch_name

- name: Get Type
id: get_type
run: |
echo ${{ steps.branch_name.outputs.current_branch }} | cut -d / -f 1
echo "TYPE=$(echo ${{ steps.branch_name.outputs.current_branch }} | cut -d / -f 1)" >> $GITHUB_OUTPUT
- name: Get Name
id: get_name
run: |
echo ${{ steps.branch_name.outputs.current_branch }} | cut -d / -f 2
echo "NAME=$(echo ${{ steps.branch_name.outputs.current_branch }} | cut -d / -f 2)" >> $GITHUB_OUTPUT
- name: Check CI Needed
id: check_ci_needed
run: |
echo ${{steps.get_type.outputs.TYPE == 'Application' || steps.get_type.outputs.TYPE == 'Modules' || steps.get_type.outputs.TYPE == 'Services'}}
echo "CI-NEEDED=${{steps.get_type.outputs.TYPE == 'Application' || steps.get_type.outputs.TYPE == 'Modules' || steps.get_type.outputs.TYPE == 'Services'}}" >> $GITHUB_OUTPUT
- name: Get Working Directory
id: get_working_directory
if: steps.check_ci_needed.outputs.CI-NEEDED == 'true'
run: |
cd ${{ steps.get_type.outputs.TYPE }}
if [ ${{ steps.get_type.outputs.TYPE }} != "Application" ]
then
cd ${{ steps.get_name.outputs.NAME }}
fi
echo "PATH=$(pwd)" >> $GITHUB_OUTPUT
- name: Check tests existence
id: check_tests_existence
if: steps.check_ci_needed.outputs.CI-NEEDED == 'true'
uses: andstor/file-existence-action@v1
with:
files: "${{ steps.get_working_directory.outputs.PATH }}/Tests"




build:
name: ⚡️ Build
runs-on: macOS-latest
needs: prepare-ci
if: needs.prepare-ci.outputs.CI-NEEDED == 'true'
name: ⚙️ Prepare CI
runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: install needs
run: |
bash <(curl -Ls https://install.tuist.io)
- name: Compute dependency cache key
id: compute_hash
run: echo "hash=${{ hashFiles('Tuist/Dependencies.swift') }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3

- name: Check dependency cache
uses: actions/cache@v3
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_hash.outputs.hash }}
- name: Install tuist
run: curl -Ls https://install.tuist.io | bash

- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: tuist fetch

- name: build codes
working-directory: ${{ needs.prepare-ci.outputs.WROKING-PATH }}
run: tuist build
- name: Compute dependency cache key
id: compute_hash
run: echo "hash=${{ hashFiles('Tuist/Dependencies.swift') }}" >> $GITHUB_OUTPUT

- name: Check dependency cache
uses: actions/cache@v3
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_hash.outputs.hash }}

- name: Install dependencies needs
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: tuist fetch
outputs:
dependency_cache_key: ${{ steps.compute_hash.outputs.hash }}

test:
name: 🧪 Test
runs-on: macOS-latest
needs: [prepare-ci]
if: needs.prepare-ci.outputs.TESTS-EXISTENCE == 'true'
runs-on: macos-latest
needs: prepare-ci

steps:
- uses: actions/checkout@v2

- name: install needs
run: |
bash <(curl -Ls https://install.tuist.io)
- name: Compute dependency cache key
id: compute_hash
run: echo "hash=${{ hashFiles('Tuist/Dependencies.swift') }}" >> $GITHUB_OUTPUT

- name: Check dependency cache
uses: actions/cache@v3
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_hash.outputs.hash }}

- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: tuist fetch

- name: test codes
working-directory: ${{ needs.prepare-ci.outputs.WROKING-PATH }}
run: tuist test ${{ needs.prepare-ci.outputs.NAME }}Test

- uses: actions/checkout@v3
with:
xcode-version: latest

- name: Install tuist
run: curl -Ls https://install.tuist.io | bash

- name: Check dependency cache
uses: actions/cache@v3
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.prepare-ci.outputs.dependency_cache_key }}

- name: Install dependencies needs
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: tuist fetch

- name: Test with tuist
run: make test
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ generate:
tuist fetch
TUIST_DEV=1 TUIST_ROOT_DIR=${PWD} tuist generate

test:
TUIST_DEV=1 TUIST_ROOT_DIR=${PWD} tuist test

clean:
rm -rf **/*.xcodeproj
rm -rf *.xcworkspace
Expand Down

0 comments on commit 11916ac

Please sign in to comment.