Skip to content

Commit

Permalink
🎆 Merge pull request #379 from COS301-SE-2024/development
Browse files Browse the repository at this point in the history
🎆 Award Merge
  • Loading branch information
ChuufMaster authored Oct 18, 2024
2 parents 8c14ae1 + 9f65116 commit e677e03
Show file tree
Hide file tree
Showing 134 changed files with 6,984 additions and 2,884 deletions.
55 changes: 55 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Add 'root' label to any root file changes
# Quotation marks are required for the leading asterisk
root:
- changed-files:
- any-glob-to-any-file: '*'

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

DevOps:
- changed-files:
- any-glob-to-any-file:
- '.github/*'
# Add 'Documentation' label to any file changes within 'docs' or 'guides' folders
Documentation:
- changed-files:
- any-glob-to-any-file:
- doc/*
- '**/*.md'
- head-branch: ['^doc', 'doc']

Dotnet:
- changed-files:
- any-glob-to-any-file:
- dotnet/*

BirdApi:
- changed-files:
- any-glob-to-any-file:
- dotnet/BirdApi/*

UserApi:
- changed-files:
- any-glob-to-any-file:
- dotnet/BirdApi/*

flutter:
- changed-files:
- any-glob-to-any-file:
- beakpeek/*

# 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: ['^dev/feat', 'feat']

fix:
- head-branch: ['^dev/fix', 'fix']

test:
- head-branch: ['^dev/test', 'test']

release:
- base-branch: 'main'
62 changes: 62 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 📄 Generate coverage for both 🥅 dotnet and 🦚 Flutter

on:
push:
branches:
- main
- development
- '**devops**'
- '**test**'
paths:
- 'beakpeek/**'
- 'dotnet/BirdApi'
- '.github/workflows/coverage.yml'

workflow_call:
workflow_dispatch:

# Don't forget that "!" is used to check if something is set

jobs:
flutter-coverage:
name: 🦚 Flutter Coverage
uses: ./.github/workflows/flutter.yml
with:
upload-coverage: true # this has to be true to not upload coverage
secrets: inherit

dotnet-coverage:
name: 🥅 Dotnet Coverage
uses: ./.github/workflows/dotnet.yml
with:
upload-coverage: true
secrets: inherit

upload-coverage:
runs-on: ubuntu-latest
name: 📔 Upload to codecov
needs: [flutter-coverage, dotnet-coverage]
steps:
- uses: actions/checkout@v4

- name: Get Flutter Code Coverage
uses: actions/download-artifact@v4
id: get-flutter-coverage
with:
name: flutter-code-coverage-${{hashFiles('beakpeek/pubspec.lock')}}

- name: Get Dotnet Code Coverage
uses: actions/download-artifact@v4
id: get-dotner-coverage
with:
name: dotnet-code-coverage-${{hashFiles('dotnet/BirdApi/BeakPeekApi/packages.lock.json', 'dotnet/BirdApi/BeakPeekApi.Tests/packages.lock.json')}}

- name: Upload coverage
# if: ${{ !env.ACT }}
uses: codecov/codecov-action@v4
with:
files: ./lcov.info, ./coverage.cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
name: BeakPeek Coverage
69 changes: 48 additions & 21 deletions .github/workflows/deploy_dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Deploy BeakPeekBirdApi
name: 🚀 Deploy Dotnet BirdApi

env:
# DOTNET_ROOT: ./dotnet/BeakPeekApi/
Expand All @@ -12,35 +9,45 @@ on:
branches:
- main
- development
paths-ignore:
- 'doc/**'
- 'res/**'
- 'beakpeek/**'
- 'dotnet/UserApi/**'
paths:
- 'dotnet/BirdApi/**'
workflow_dispatch:
workflow_call:

jobs:
test:
test_dotnet:
name: 🧪 Test dotnet BirdApi
uses: ./.github/workflows/dotnet.yml
secrets: inherit

build:
name: 🏛️ Build BirdApi
runs-on: ubuntu-latest
# needs: test

needs: [ test_dotnet ]
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/birdapi/packages
outputs:
artifact_url: ${{ steps.artifact-upload-step.outputs.artifact-url}}
steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
include-prerelease: true
cache: true
cache-dependency-path: ./dotnet/BirdApi/BeakPeekApi/packages.lock.json

- name: Get App Setting
run: |
cd ./dotnet/BirdApi/BeakPeekApi
cp ../../../appsettings.json .
- name: Restore Dependencies
run: |
cd ./dotnet/BirdApi/BeakPeekApi
dotnet restore --locked-mode
- name: Build with dotnet
run: dotnet build --configuration Release ./dotnet/BirdApi/BeakPeekApi/BeakPeekApi.csproj

Expand All @@ -55,14 +62,16 @@ jobs:
cp -r ./res/species_list/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: .net-app
name: dotnet-birdapi
path: ${{env.DOTNET_ROOT}}/BeakPeekApi

deploy:
runs-on: ubuntu-latest
needs: build
name: 🚀 Deploy BirdApi
needs: [ build ]
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
Expand All @@ -71,10 +80,10 @@ jobs:

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: .net-app
name: dotnet-birdapi

- name: Login to Azure
uses: azure/login@v1
with:
Expand All @@ -89,4 +98,22 @@ jobs:
app-name: 'BeakPeekBirdApi'
slot-name: 'Production'
package: .


notify_discord:
name: 🔔 Send Discord notification about deployment
needs: [deploy, build]
if: ${{ !cancelled() && (success() || failure()) }}
uses: ./.github/workflows/discord.yml
with:
content: "${{ contains(needs.deploy.result, 'success') && 'Successfully deployed' || 'Error during deployment of' }} ${{ github.ref_name }} for Azure"
title: "${{ contains(needs.deploy.result, 'success') && 'Successfully deployed' || 'Error during deployment of' }} ${{ github.ref_name }} for Azure"
url: ${{ needs.build.outputs.artifact_url }}
description: "${{ contains(needs.deploy.result, 'success') && 'Deployed:' || 'Deployment failed:' }} ${{ github.event.head_commit.message }}"
color: ${{ contains(needs.deploy.result, 'success') && 65280 || 16711680 }}
secrets: inherit

update_birds:
needs: [deploy]
name: 🦚 Update production birds
uses: ./.github/workflows/update_birds.yml
secrets: inherit
114 changes: 114 additions & 0 deletions .github/workflows/deploy_flutter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: 📢 Publish Android release

on:
release:
types: [published]
workflow_dispatch:
workflow_call:

env:
FLUTTER_CHANNEL: "stable"
RUBY_VERSION: "3.2.2"

jobs:
test_android:
name: 🧪 Test Flutter
uses: ./.github/workflows/flutter.yml
secrets: inherit

build_android:
name: 🏛️ Build Android
needs: [test_android]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./beakpeek
timeout-minutes: 20
outputs:
artifact_url: ${{ steps.artifact-upload-step.outputs.artifact-url}}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
if: ${{ env.ACT }}
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Android SDK
if: ${{ env.ACT }}
uses: android-actions/setup-android@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
working-directory: './beakpeek/android'

- name: Run Flutter tasks
uses: subosito/[email protected]
with:
channel: stable
cache: true
pub-cache-key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}

- name: Create google_service_account.json
run: |
pwd
echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_BASE64 }}" | base64 --decode > google_service_account.json
- name: Create key.jks
run: |
pwd
echo "${{ secrets.ANDROID_KEYSTORE_FILE_BASE64 }}" | base64 --decode > android/app/upload-keystore.jks
- name: Create local.properties
run: |
pwd
echo "${{ secrets.ANDROID_LOCAL_PROPERTIES_FILE_BASE64 }}" | base64 --decode > android/local.properties
- name: Create key.properties
run: |
echo $PATH
pwd
cat <<EOF > android/key.properties
storePassword=${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyPassword=${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyAlias=upload
storeFile=\\\upload-keystore.jks
EOF
env:
ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}

- name: Build and Release to Google Play
uses: maierj/[email protected]
with:
lane: 'release_play_store'
subdirectory: ./beakpeek/android
options: '{ "version_number": "${{ github.ref_name }}" }'
env:
APP_PACKAGE_NAME: ${{ secrets.APP_PACKAGE_NAME }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: app-release
path: beakpeek/build/app/outputs/bundle/release/app-release.aab

notify_discord:
name: 🔔 Send Discord notification about Build
needs: [build_android]
if: ${{ !cancelled() && (success() || failure()) }}
uses: ./.github/workflows/discord.yml
with:
content: "${{ contains(needs.build_android.result, 'success') && 'Successfully released' || 'Error during release of' }} ${{ github.ref_name }} for Android to Play Store"
title: "${{ contains(needs.build_android.result, 'success') && 'Successfully released' || 'Error during release of' }} ${{ github.ref_name }} for Android to Play Store"
url: ${{ needs.build_android.outputs.artifact_url }}
description: "${{ contains(needs.build_android.result, 'success') && 'Released:' || 'Release failed:' }} ${{ github.event.head_commit.message }}"
color: ${{ contains(needs.build_android.result, 'success') && 65280 || 16711680 }}
secrets: inherit

Loading

0 comments on commit e677e03

Please sign in to comment.