Merge pull request #136 from gertrude-app/ios-ci #354
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: basic-ci | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
linux-build-libs-1: | |
runs-on: namespace-profile-default | |
container: swift:5.10-focal | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: build-duet | |
run: cd duet && swift build | |
- name: build-pairql | |
run: cd pairql && swift build | |
- name: build-pairql-macapp | |
run: cd pairql-macapp && swift build | |
linux-build-libs-2: | |
runs-on: namespace-profile-default | |
container: swift:5.10-focal | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: build-gertie | |
run: cd gertie && swift build | |
- name: build-ts-interop | |
run: cd ts-interop && swift build | |
- name: build-x-expect | |
run: cd x-expect && swift build | |
- name: build-x-http | |
run: cd x-http && swift build | |
- name: build-x-kit | |
run: cd x-kit && swift build | |
- name: build-x-postmark | |
run: cd x-postmark && swift build | |
- name: build-x-slack | |
run: cd x-slack && swift build | |
- name: build-x-stripe | |
run: cd x-stripe && swift build | |
linux-lib-test-libs-1: | |
runs-on: namespace-profile-default | |
container: swift:5.10-focal | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: test-duet | |
run: cd duet && swift test | |
- name: test-pairql | |
run: cd pairql && swift test | |
linux-lib-test-libs-2: | |
runs-on: namespace-profile-default | |
container: swift:5.10-focal | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: test-pairql-macapp | |
run: cd pairql-macapp && swift test | |
- name: test-ts-interop | |
run: cd ts-interop && swift test | |
- name: test-gertie | |
run: cd gertie && swift test | |
- name: test-x-http | |
run: cd x-http && swift test | |
- name: test-x-kit | |
run: cd x-kit && swift test | |
- name: test-x-slack | |
run: cd x-slack && swift test | |
linux-api-build: | |
runs-on: namespace-profile-default | |
container: swift:5.10-focal | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: api/.build | |
key: api-build-${{ hashFiles('api/Package.resolved') }} | |
restore-keys: api-build- | |
- name: meta | |
id: meta | |
uses: friends-library/dev/actions/ts-pack/actions/meta@master | |
with: | |
github_token: ${{ github.token }} | |
- name: set-env-vars | |
run: | | |
DATESTR=$(TZ=America/New_York date +'%Y.%m.%d_%H.%M') | |
SHORTSHA=${{ steps.meta.outputs.latest_commit_sha_short }} | |
if [ "${{ github.ref }}" = "refs/heads/master" ]; then | |
API_ENV=production | |
echo "SRCDIR=api/.build/release" >> $GITHUB_ENV | |
echo "DESTDIR=builds/production" >> $GITHUB_ENV | |
echo "CONFIGURATION=release" >> $GITHUB_ENV | |
else | |
API_ENV=staging | |
echo "SRCDIR=api/.build/debug" >> $GITHUB_ENV | |
echo "DESTDIR=builds/staging" >> $GITHUB_ENV | |
echo "CONFIGURATION=debug" >> $GITHUB_ENV | |
fi | |
echo "FILENAME=api_${API_ENV}_${DATESTR}_${SHORTSHA}" >> $GITHUB_ENV | |
- name: build-api | |
run: | | |
cd api && swift build --static-swift-stdlib -c $CONFIGURATION | |
cd ../ && cp ${SRCDIR}/Run ${FILENAME} | |
- name: scp-bin | |
uses: appleboy/[email protected] | |
with: | |
host: api.gertrude.app | |
username: ${{ secrets.API_SERVER_SSH_USER }} | |
key: ${{ secrets.API_SERVER_SSH_KEY }} | |
source: '${{ env.FILENAME }}' | |
target: '${{ env.DESTDIR }}' | |
- name: ssh-tasks | |
uses: appleboy/[email protected] | |
with: | |
host: api.gertrude.app | |
username: ${{ secrets.API_SERVER_SSH_USER }} | |
key: ${{ secrets.API_SERVER_SSH_KEY }} | |
envs: DESTDIR,FILENAME | |
script: | | |
ln -sf "./${FILENAME}" "${DESTDIR}/latest" | |
chmod +x "${DESTDIR}/${FILENAME}" "${DESTDIR}/latest" | |
cd ~/builds/production && ls -r api_* | grep -v $(basename $(readlink -f current)) | tail -n +11 | xargs rm | |
cd ~/builds/staging && ls -r api_* | tail -n +6 | xargs rm | |
pm2 restart staging > /dev/null | |
linux-api-test: | |
runs-on: namespace-profile-default | |
container: swift:5.10-focal | |
env: | |
DATABASE_HOST: postgres | |
AUTO_INCLUDED_KEYCHAIN_ID: 77777777-7777-7777-7777-777777777777 | |
SLACK_API_TOKEN: not-real | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: vapor_username | |
POSTGRES_PASSWORD: vapor_password | |
POSTGRES_DB: vapor_database | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
# only restore, job:linux-api-build will save, to save execution time | |
- uses: actions/cache/restore@v4 | |
with: | |
path: api/.build | |
key: api-test-${{ hashFiles('api/Package.resolved') }} | |
restore-keys: api-test- | |
- name: test-api | |
run: cd api && swift test | |
files-changed: | |
runs-on: namespace-profile-default | |
outputs: | |
macapp: ${{ steps.changes.outputs.macapp }} | |
iosapp: ${{ steps.changes.outputs.iosapp }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
macapp: | |
- macapp/App/** | |
- pairql-macapp/** | |
- gertie/** | |
- x-kit/** | |
- ts-interop/** | |
iosapp: | |
- iosapp/lib-ios/** | |
- pairql-iosapp/** | |
- gertie/** | |
- x-kit/** | |
macapp-lib: | |
needs: files-changed | |
if: needs.files-changed.outputs.macapp == 'true' | |
runs-on: macos-14 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: setup xcode | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: 15.3.0 | |
- uses: actions/cache@v4 | |
with: | |
path: macapp/App/.build | |
key: macapp-xc15.3.0--${{ hashFiles('macapp/App/Package.resolved') }} | |
restore-keys: macapp-xc15.3.0-- | |
- name: build | |
run: cd macapp/App && swift build | |
- name: test | |
run: cd macapp/App && swift test | |
iosapp-lib: | |
needs: files-changed | |
if: needs.files-changed.outputs.iosapp == 'true' | |
runs-on: macos-14 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: setup xcode | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: 15.3.0 | |
- uses: actions/cache@v4 | |
with: | |
path: iosapp/lib-ios/.build | |
key: iosapp-xc15.3.0--${{ hashFiles('iosapp/lib-ios/Package.resolved') }} | |
restore-keys: iosapp-xc15.3.0-- | |
- name: build | |
run: cd iosapp/lib-ios && swift build | |
- name: test | |
run: cd iosapp/lib-ios && swift test | |
# env | |
env: | |
DATABASE_NAME: vapor_database | |
DATABASE_USERNAME: vapor_username | |
DATABASE_PASSWORD: vapor_password | |
TEST_DATABASE_NAME: vapor_database | |
CLOUD_STORAGE_KEY: not-real | |
CLOUD_STORAGE_SECRET: not-real | |
CLOUD_STORAGE_ENDPOINT: not-real | |
CLOUD_STORAGE_BUCKET: not-real | |
CLOUD_STORAGE_BUCKET_URL: /not-real | |
CLOUDFLARE_SECRET: not-real | |
TWILIO_ACCOUNT_SID: not-real | |
TWILIO_AUTH_TOKEN: not-real | |
TWILIO_FROM_PHONE: not-real | |
DASHBOARD_URL: /dashboard | |
ANALYTICS_SITE_URL: /analytics | |
POSTMARK_API_KEY: not-real | |
POSTMARK_SERVER_ID: 12345 | |
PRIMARY_SUPPORT_EMAIL: not-real | |
SUPER_ADMIN_EMAIL: not-real | |
STRIPE_SUBSCRIPTION_PRICE_ID: not-real | |
STRIPE_SECRET_KEY: not-real | |
SWIFT_DETERMINISTIC_HASHING: 1 | |
TASK_MEGA_YIELD_COUNT: 50 |