chore: add ci (#6)

* chore: add ci

* chore: github action apk
This commit is contained in:
cl.st authored and GitHub committed 2024-05-20 22:15:48 +02:00
1 parent a4f1c3e7f5
commit edeb1fbac8
34 files changed
+5034 -2736

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
name: Delete
on:
delete:
branches-ignore: [main, gh-pages]
# ensures that currently running Playwright workflow of deleted branch gets cancelled
concurrency:
group: ${{ github.event.ref }}
cancel-in-progress: true
jobs:
delete_reports:
name: Delete Reports
runs-on: ubuntu-latest
env:
# Contains all reports for deleted branch
BRANCH_REPORTS_DIR: reports/${{ github.event.ref }}
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Set Git User
# see: https://github.com/actions/checkout/issues/13#issuecomment-724415212
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Check for workflow reports
run: |
if [ -z "$(ls -A $BRANCH_REPORTS_DIR)" ]; then
echo "BRANCH_REPORTS_EXIST="false"" >> $GITHUB_ENV
else
echo "BRANCH_REPORTS_EXIST="true"" >> $GITHUB_ENV
fi
- name: Delete reports from repo for branch
if: ${{ env.BRANCH_REPORTS_EXIST == 'true' }}
timeout-minutes: 3
run: |
cd $BRANCH_REPORTS_DIR/..
rm -rf ${{ github.event.ref }}
git add .
git commit -m "workflow: remove all reports for branch ${{ github.event.ref }}"
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML reports to repo."
exit 0
fi
done
+52
View File
@@ -0,0 +1,52 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# ESLint is a tool for identifying and reporting on patterns
# found in ECMAScript/JavaScript code.
# More details at https://github.com/eslint/eslint
# and https://eslint.org
name: ESLint
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install ESLint + Prettier
run: |
npm install eslint@8.56.0
npm install @typescript-eslint/eslint-plugin@latest
npm install @microsoft/eslint-formatter-sarif@3.1
npm install eslint-plugin-jsx-a11y
npm install eslint-config-prettier
npm install eslint-plugin-prettier
npm install prettier
- name: Check code lint and format
run: npx eslint .
--config ./.eslintrc.json
--ext .js,.jsx,.ts,.tsx
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
+84
View File
@@ -0,0 +1,84 @@
name: APK deployment Workflow
on:
# workflow_dispatch:
push:
branches-ignore: [main, gh-pages]
# branches: master
# tags:
# - v*
# Job 1 - Build Signed AAB
jobs:
build:
name: Build Signed APK
runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Setup build tool version variable
shell: bash
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: Install app dependencies
run: npm install
- name: Build project app
run: npm run build
- name: Capacitor copy
run: npx cap copy android
- name: Capacitor update
run: npx cap update android
- name: Setup JDK 20
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 20
- name: Make gradlew executable
working-directory: ./android
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build
working-directory: ./android
run: ./gradlew build --scan
- name: Sign APK
id: sign_app
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: android/app/build/outputs/apk/release/
signingKeyBase64: ${{ secrets.KEYSTORE }}
alias: ${{ secrets.SIGNING_KEY_ALIAS }}
keyStorePassword: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: Upload app apk as artifact
uses: actions/upload-artifact@v4
with:
name: app-bundle
path: ${{steps.sign_app.outputs.signedReleaseFile}}
# - name: Create Github Release
# uses: softprops/action-gh-release@v2
# with:
# generate_release_notes: true
# prerelease: true
# files: |
# app/build/outputs/apk/release/app-release.apk
- run: echo Build status report=${{ job.status }}
+85
View File
@@ -0,0 +1,85 @@
name: Playwright Tests
on:
push:
branches-ignore: [ main, gh-pages ]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
name: 'Playwright Tests'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install dependencies
run: npm install
- name: Run Playwright tests
run: npm run testing:ci
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: ./testing/playwright-report/
retention-days: 30
publish_report:
name: Publish HTML Report
# using always() is not ideal here, because it would also run if the workflow was cancelled
if: "success() || needs.test.result == 'failure'"
needs: [test]
runs-on: ubuntu-latest
continue-on-error: true
env:
# Unique URL path for each workflow run attempt
HTML_REPORT_URL_PATH: reports/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }}
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Set Git User
# see: https://github.com/actions/checkout/issues/13#issuecomment-724415212
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
echo ${{ env.HTML_REPORT_URL_PATH }}
- name: Download zipped HTML report
uses: actions/download-artifact@v4
with:
name: playwright-report
path: ${{ env.HTML_REPORT_URL_PATH }}
- name: Log
run: |
pwd
ls -la
ls -la reports
- name: Push HTML Report
timeout-minutes: 3
# commit report, then try push-rebase-loop until it's able to merge the HTML report to the gh-pages branch
# this is necessary when this job is running at least twice at the same time (e.g. through two pushes at the same time)
run: |
git add .
git commit -m "workflow: add HTML report for run-id ${{ github.run_id }} (attempt: ${{ github.run_attempt }})"
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML report to repo."
exit 0
fi
done
- name: Output Report URL as Worfklow Annotation
run: |
FULL_HTML_REPORT_URL=https://cstaelen.github.io/shazarr-app/$HTML_REPORT_URL_PATH
echo "::notice title=📋 Published Playwright Test Report::$FULL_HTML_REPORT_URL"