Develop : CI/CD Pipeline #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Flutter E2E (android) test | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
e2e: | |
runs-on: ubuntu-latest | |
outputs: | |
SLACK_MESSAGE_TITLE: Flutter E2E Test on ${{ matrix.os }} ${{ matrix.os_version }} | |
TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} | |
URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} | |
strategy: # 테스트를 하고자 하는 디바이스 설정 | |
matrix: | |
os: ["Android API"] | |
include: | |
- device_model: "oriole" | |
os_version: "33" | |
steps: | |
# 1. 코드 체크아웃 | |
- name: Github Checkout | |
uses: actions/checkout@v3 | |
# 2.1 Flutter 설치 | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
# 2.2. 의존성 설치 | |
- name: Install dependencies | |
run: flutter pub get | |
# 2.3. Gradle wrapper 생성 | |
- name: Generate Gradle wrapper | |
run: flutter build apk --config-only | |
# 3.1. Patrol CLI 설치 | |
- name: Set up Patrol CLI | |
run: dart pub global activate patrol_cli | |
# 3.2. Patrol 빌드 | |
- name: patrol build android | |
run: patrol build android | |
# 4.1. service-account.json 인증 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: "${{secrets.GCP_STAGE_SERVICE_ACCOUNT_JSON}}" | |
# 4.2. gcloud 설정 | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
# 4.3 ENV 설정 | |
- name: Create .env File | |
uses: iamsauravsharma/create-dotenv@v1.2.2 | |
with: | |
env-prefix: "envkey_" | |
file-name: ".env" | |
directory: "/home/runner/work/tunefun_front/assets/config/" | |
env: | |
IS_SERVER: true | |
PUBLIC_BASE_URL: ${{secrets.PUBLIC_BASE_URL}} | |
PUBLIC_USER_REGISTER_URL: ${{secrets.PUBLIC_USER_REGISTER_URL}} | |
PUBLIC_USER_LOGIN_URL: ${{secrets.PUBLIC_USER_LOGIN_URL}} | |
PUBLIC_USER_LOGOUT_URL: ${{secrets.PUBLIC_USER_LOGOUT_URL}} | |
PUBLIC_USER_FIND_USERNAME: ${{secrets.PUBLIC_USER_FIND_USERNAME}} | |
PUBLIC_USER_ACCESS_TOKEN: ${{secrets.PUBLIC_USER_ACCESS_TOKEN}} | |
PUBLIC_USER_SET_NEW_PASSWORD: ${{secrets.PUBLIC_USER_SET_NEW_PASSWORD}} | |
PUBLIC_USER_UPDATE_NICKNAME: ${{secrets.PUBLIC_USER_UPDATE_NICKNAME}} | |
PUBLIC_USER_FORGOT_PASSWORD_SEND_OTP: ${{secrets.PUBLIC_USER_FORGOT_PASSWORD_SEND_OTP}} | |
PUBLIC_USER_OTP_RESEND: ${{secrets.PUBLIC_USER_OTP_RESEND}} | |
PUBLIC_USER_OTP_VERIFY: ${{secrets.PUBLIC_USER_OTP_VERIFY}} | |
PUBLIC_USER_CHECK_EMAIL_DUPLICATE: ${{secrets.PUBLIC_USER_CHECK_EMAIL_DUPLICATE}} | |
PUBLIC_USER_CHECK_EMAIL_VERIFIED: ${{secrets.PUBLIC_USER_CHECK_EMAIL_VERIFIED}} | |
PUBLIC_USER_CHECK_USERNAME_DUPLICATE: ${{secrets.PUBLIC_USER_CHECK_USERNAME_DUPLICATE}} | |
# 5. Firebase Test Lab 에 APK 업로드 및 테스트 실행 | |
- name: Upload APKs to Firebase Test Lab and wait for tests to finish | |
id: tests_step | |
env: | |
ANDROID_DEVICE_MODEL: ${{ matrix.device_model }} | |
ANDROID_DEVICE_VERSION: ${{ matrix.os_version }} | |
run: | | |
set +e | |
set -euo pipefail | |
# Firebase Test Lab 실행 및 결과 저장 | |
output=$(set -euo pipefail && \ | |
gcloud firebase test android run \ | |
--type instrumentation \ | |
--app build/app/outputs/apk/debug/app-debug.apk \ | |
--test build/app/outputs/apk/androidTest/debug/ap-debug-androidTest.apk \ | |
--device model="$ANDROID_DEVICE_MODEL",version="$ANDROID_DEVICE_VERSION",locale=en,orientation=portrait \ | |
--timeout 10m \ | |
--results-bucket="tunefun-6edf5.appspot.com" \ | |
--use-orchestrator \ | |
--environment-variables clearPackageData=true 2>&1) | |
TESTS_EXIT_CODE=$? | |
set -e | |
# Extract the last link using grep, tail, and sed, and write it to Github Summary | |
link="$(echo "$output" | grep -o 'https://[^ ]*' | tail -1 | sed 's/\[//;s/\]//')" | |
echo "[Test details on Firebase Test Lab]($link) (Firebase members only)" >> "$GITHUB_STEP_SUMMARY" | |
echo "URL_TO_DETAILS=$link" >> "$GITHUB_OUTPUT" | |
echo "TESTS_EXIT_CODE=$TESTS_EXIT_CODE" >> "$GITHUB_OUTPUT" | |
exit $TESTS_EXIT_CODE | |
# 6. Slack 메시지 전송 | |
# call_send_slack_message: | |
# name: Notify on Slack | |
# uses: ./.github/workflows/send_slack_message.yml | |
# needs: e2e | |
# if: always() | |
# with: | |
# TESTS_EXIT_CODE: ${{ needs.e2e.outputs.TESTS_EXIT_CODE }} | |
# SLACK_MESSAGE_TITLE: ${{ needs.e2e.outputs.SLACK_MESSAGE_TITLE }} | |
# URL_TO_DETAILS: ${{ needs.e2e.outputs.URL_TO_DETAILS }} | |
# secrets: inherit |