Skip to content

Commit

Permalink
Merge branch 'andrew_testing' into eliyas/type_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pinocchio-life-like authored May 4, 2024
2 parents 5010884 + a20f270 commit d13faa5
Show file tree
Hide file tree
Showing 33 changed files with 436 additions and 216 deletions.
5 changes: 1 addition & 4 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: 'Install Dependencies'
description: 'Install Node.js dependencies'

runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v2

# Cache yarn packages to speed up installation
- name: Cache Yarn packages
uses: actions/cache@v2
with:
Expand All @@ -16,7 +14,6 @@ runs:
restore-keys: |
${{ runner.os }}-yarn-
# Install dependencies
- name: Install dependencies
run: yarn install --immutable
shell: bash
shell: bash
22 changes: 22 additions & 0 deletions .github/actions/setup-js-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Setup JS Runtime Environment'
description: 'Sets up Node.js and caches Node modules'
runs:
using: 'composite'
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'yarn'

- name: Cache Yarn packages
uses: actions/cache@v2
with:
path: ~/.yarn/cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --immutable
shell: bash
88 changes: 36 additions & 52 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,61 @@
# Add 'root' label to any root file changes
# Quotation marks are required for the leading asterisk
root:
- changed-files:
- any-glob-to-any-file: '*'
- changed-files:
- any-glob-to-any-file: '*'

## Equivalent of the above mentioned configuration using another syntax
docs:
- changed-files:
- any-glob-to-any-file: ['docs/*', 'guides/*', '**/*.md']
- changed-files:
- any-glob-to-any-file: '{docs/**/*,guides/**/*,**/*.md}'

# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
feature:
- head-branch: ['^feature', 'feature']
- head-branch: ['^feature', 'feature']

# Add 'release' label to any PR that is opened against the `main` branch
release:
- base-branch: 'main'
- base-branch: 'main'

# Add 'test' label to any change to *.spec.ts, *.spec.js, *.test.ts, *.test.js files within the entire repository
test:
- changed-files:
- any-glob-to-any-file:
- '**/*.spec.ts'
- '**/*.spec.js'
- '**/*.test.ts'
- '**/*.test.js'
- '**/tests/**/*.ts'
- '**/tests/**/*.js'
- changed-files:
- any-glob-to-any-file:
- '**/*.spec.ts'
- '**/*.spec.js'
- '**/*.test.ts'
- '**/*.test.js'
- '**/tests/**/*.ts'
- '**/tests/**/*.js'

# Add 'frontend' label to any change in the 'client' directory
frontend:
- changed-files:
- any-glob-to-any-file:
- 'apps/**/*.{ts,js}'
- any: 'apps/**/*.ts'
- any: 'apps/**/*.js'
- all-globs-to-all-files:
- '!apps/src/main.ts'
- '!apps/src/main.js'
- changed-files:
- any-glob-to-any-file: 'apps/**/*.{ts,js, jsx, tsx}'

# Add 'backend' label to any change in the 'server' directory
backend:
- changed-files:
- any-glob-to-any-file: 'server/**/*.{ts,js}'
- changed-files:
- any-glob-to-any-file: 'server/**/*.{ts,js}'

# Add the 'AnyChange' label to any changes within the entire repository
AnyChange:
- changed-files:
- any-glob-to-any-file: '**'
- changed-files:
- any-glob-to-any-file: '*'

# Add 'client' label to any change in the 'apps' directory
client:
- changed-files:
- any-glob-to-any-file: 'apps/**/*'
- changed-files:
- any-glob-to-any-file: 'apps/**/*'

# Add 'expo' label to any changes in the 'apps/expo' directory
expo:
- changed-files:
- any-glob-to-any-file: 'apps/expo/**/*'
- changed-files:
- any-glob-to-any-file: 'apps/expo/**/*'

# Add 'next' label to any changes in the 'apps/next' directory
next:
- changed-files:
- any-glob-to-any-file: 'apps/next/**/*'
- changed-files:
- any-glob-to-any-file: 'apps/next/**/*'

# Add 'vite' label to any changes in the 'apps/vite' directory
vite:
- changed-files:
- any-glob-to-any-file: 'apps/vite/**/*'
- changed-files:
- any-glob-to-any-file: 'apps/vite/**/*'

# Add 'api' label to any changes in the 'api' or 'server' directories
api:
- changed-files:
- any-glob-to-any-file:
- 'api/**/*'
- 'server/**/*'
- changed-files:
- any-glob-to-any-file:
- 'api/**/*'
- 'server/**/*'

github:
- changed-files:
- any-glob-to-any-file: '.github/**/*'
21 changes: 20 additions & 1 deletion .github/scripts/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,23 @@ const viteFileContent = envFileContent
.join('\n');
fs.writeFileSync(viteOutputPath, `${autogeneratedComment}\n${viteFileContent}`);

// TODO: Add wrangler env generation
// TODO: Add wrangler env generation
/**
* Generate Cloudflare Wrangler .dev.vars file content
*/
// const wranglerOutputPath = path.join(__dirname, '..', '..', 'packages', 'api', '.dev.vars')
// // Remove public variables from output
// const wranglerFileContent = envFileContent
// .split('\n')
// .map((line) => {
// if (line.startsWith('PUBLIC_APP_URL')) return line.replace(/^PUBLIC_APP_URL/, 'APP_URL')
// if (!line.startsWith('PUBLIC_')) {
// return line
// }
// })
// .join('\n')
// const noD1Warning = 'NO_D1_WARNING=true'
// fs.writeFileSync(
// wranglerOutputPath,
// `${autogeneratedComment}\n${wranglerFileContent}\n${noD1Warning}`
// )
66 changes: 57 additions & 9 deletions .github/workflows/android-preview-build-local.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: android-preview-build-local
on:
push:
branches: [ "**" ]
branches: ['**']
pull_request:
branches: [ "**" ]
branches: ['**']

jobs:
update:
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
echo "apk_path=${apk_path}" >> $GITHUB_ENV
working-directory: apps/expo
env:
DEBUG: "true"
DEBUG: 'true'
continue-on-error: true

- name: Upload APK
Expand All @@ -74,10 +74,58 @@ jobs:
name: android-apk
path: /home/runner/work/PackRat/PackRat/apps/expo/build-*.apk

- name: Create Commit Comment
if: github.event_name == 'push'
uses: peter-evans/commit-comment@v2
- name: Find or create comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
id: find_or_create_comment
with:
body: |
Android APK build ${{ steps.build.outcome == 'success' && 'completed' || 'failed' }}!
${{ steps.build.outcome == 'success' && format('You can download the APK file from the following link:\nhttps://github.com/{0}/actions/runs/{1}#artifacts', github.repository, github.run_id) || 'Please check the workflow logs for more details on the build failure.' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commentIdentifier = '<!-- build_results -->';
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const existingComment = comments.data.find(comment => comment.body.startsWith(commentIdentifier));
if (existingComment) {
core.setOutput('comment_id', existingComment.id);
} else {
const commentBody = `${commentIdentifier}\n🚀 Android APK build started... Please wait for the results! 🕐`;
const { data: { id: commentId } } = await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
core.setOutput('comment_id', commentId);
}
- name: Update PR comment
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commentIdentifier = '<!-- build_results -->';
const commentId = '${{ steps.find_or_create_comment.outputs.comment_id }}';
const buildOutcome = '${{ steps.build.outcome }}';
const buildStatus = buildOutcome == 'success' ? 'completed' : 'failed';
const workflowUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
let commentBody = `${commentIdentifier}\nAndroid APK build ${buildStatus}!`;
if (buildOutcome == 'success') {
commentBody += `\nYou can download the APK file from the following link:\n${workflowUrl}#artifacts`;
} else {
commentBody += '\nPlease check the workflow logs for more details on the build failure.';
}
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId,
body: commentBody
});
36 changes: 28 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
name: android-build-apk
on:
push:
branches: [ "**" ]
branches: ['**']
pull_request:
branches: [ "**" ]
branches: ['**']

jobs:
install-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install yarn dependencies
run: |
yarn install

- name: Install dependencies
uses: ./.github/actions/install-deps
build-android:
needs: install-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install yarn dependencies

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: yarn

- name: Install dependencies
uses: ./.github/actions/install-deps

- name: Prebuild
run: |
yarn install
echo "Using Mapbox Token: $MAPBOX_DOWNLOADS_TOKEN"
export MAPBOX_DOWNLOADS_TOKEN=${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}
yarn run prebuild:expo
- name: Build Android Release
run: |
cd apps/expo/android && ./gradlew assembleRelease
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: app-release.apk
path: android/app/build/outputs/apk/release/
path: android/app/build/outputs/apk/release/
54 changes: 54 additions & 0 deletions .github/workflows/deployments/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Backend Deployment'

on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'packages/api/**'
- 'server/**'

jobs:
deploy:
name: Deploy to Cloudflare Workers
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Setup JS Runtime environment
uses: ./.github/actions/setup-js-runtime

- name: Install dependencies
uses: ./.github/actions/install-deps

- name: Migrate database
# run: cd packages/api && bun run migrate
run: cd server && yarn run migrate:prod
env:
NO_D1_WARNING: true
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}

- name: Deploy
uses: cloudflare/[email protected]
with:
wranglerVersion: '3.15.0'
apiToken: ${{ secrets.CF_API_TOKEN }}
# workingDirectory: packages/api
workingDirectory: server
command: yarn run deploy:prod
packageManager: bun
secrets: |
APP_URL
JWT_VERIFICATION_KEY
CI
env:
APP_URL: ${{ secrets.NEXT_PUBLIC_APP_URL }}
JWT_VERIFICATION_KEY: ${{ secrets.JWT_VERIFICATION_KEY }}
CI: true
NO_D1_WARNING: true
Loading

0 comments on commit d13faa5

Please sign in to comment.