Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Fix readme path in shell script #6

Fix readme path in shell script

Fix readme path in shell script #6

Workflow file for this run

name: GitHub Classroom Workflow
#######################################################################
# Note for students: DO NOT edit/delete any file under '.github' folder
#######################################################################
on:
push:
branches:
- main
workflow_dispatch:
permissions:
checks: write
actions: read
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
ANDROID_APP_PATH: "application"
README_PATH: ""
IMG_API_LEVEL: 29
AVD_NAME: "test"
jobs:
check-android-project:
name: Check Android Project
runs-on: ubuntu-latest
if: github.actor != 'github-classroom[bot]'
steps:
#Get the code
- uses: actions/checkout@v4
# Check if the application folder contains an Android project
- name: Check for Android project
run: |
if [ -f "${{env.ANDROID_APP_PATH}}/build.gradle" ] || [ -f "${{env.ANDROID_APP_PATH}}/build.gradle.kts" ]; then
echo "Android project found"
if [ -n "$(find ${{env.ANDROID_APP_PATH}}/app/src/main/java -name "*.kt" -type f)" ]; then
echo "Module app is written in Kotlin"
exit 1
else
echo "Module app is written in Java"
fi
else
echo "No Android project found"
exit 1
fi
build:
name: Autograding
runs-on: ubuntu-latest
if: github.actor != 'github-classroom[bot]'
needs: [check-android-project]
steps:
# Get the code
- uses: actions/checkout@v4
# Enable KVM for emulator
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Make all scripts executable
run: |
find .github/scripts -type f -name "*.sh" -exec chmod +x {} \;
chmod +x ${{env.ANDROID_APP_PATH}}/gradlew
# Setup min version of Java required by Gradle v8
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
# Let gradle action handle all cache reated to gradle operations
- name: Gradle setup/cache
uses: gradle/actions/setup-gradle@v3
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-use-agree: "yes"
# Save/Restore avd cache for faster boot
- name: AVD cache
uses: actions/cache@v4
id: avd-cache-new
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-eval-test-new
# Export Android paths
- name: Export Android paths
run: |
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
echo "$ANDROID_HOME/cmdline-tools/latest" >> $GITHUB_PATH
echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> $GITHUB_PATH
echo "ANDROID_AVD_HOME=$HOME/.android/avd" >> $GITHUB_ENV
# Check Android Sdk packages
- name: Check Android Sdk
run: ./.github/scripts/install_android_sdk.sh
# Create an AVD if it's not cached yet
- name: Generate an AVD snapshot for caching
if: steps.avd-cache-new.outputs.cache-hit != 'true'
run: |
./.github/scripts/create_avd.sh
./.github/scripts/stop_emulators.sh
echo "Generated AVD snapshot for caching."
# Setup/Start the emulator to launch instrumented tests
- name: Setup & Start Emulator
timeout-minutes: 10
run: bash .github/scripts/start_emulator.sh
# Create env that need to be injected to child process
- name: Create file for setting env vars
# https://github.com/education/autograding/issues/69#issuecomment-1497674655
# https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow
env:
ANSWERS_SECRET_PASSPHRASE: ${{ secrets.ANSWERS_SECRET_PASSPHRASE }}
run: |
echo "#!/bin/sh" > setenv.sh
echo "export ANSWERS_SECRET_PASSPHRASE=\"$ANSWERS_SECRET_PASSPHRASE\"" >> setenv.sh
echo "export README_PATH=\"$README_PATH\"" >> setenv.sh
echo "export ANDROID_APP_PATH=\"$ANDROID_APP_PATH\"" >> setenv.sh
echo "export ANDROID_HOME=\"$ANDROID_HOME\"" >> setenv.sh
echo "export IMG_API_LEVEL=\"$IMG_API_LEVEL\"" >> setenv.sh
echo "export AVD_NAME=\"$AVD_NAME\"" >> setenv.sh
echo "export GRADLE_BUILD_ACTION_SETUP_COMPLETED=\"$GRADLE_BUILD_ACTION_SETUP_COMPLETED\"" >> setenv.sh
echo "export GRADLE_BUILD_ACTION_CACHE_RESTORED=\"$GRADLE_BUILD_ACTION_CACHE_RESTORED\"" >> setenv.sh
echo "export DEVELOCITY_INJECTION_ENABLED=\"$DEVELOCITY_INJECTION_ENABLED\"" >> setenv.sh
echo "export DEVELOCITY_PLUGIN_VERSION=\"$DEVELOCITY_PLUGIN_VERSION\"" >> setenv.sh
echo "export DEVELOCITY_CCUD_PLUGIN_VERSION=\"$DEVELOCITY_CCUD_PLUGIN_VERSION\"" >> setenv.sh
echo "export BUILD_SCAN_TERMS_OF_SERVICE_URL=\"$BUILD_SCAN_TERMS_OF_SERVICE_URL\"" >> setenv.sh
echo "export BUILD_SCAN_TERMS_OF_SERVICE_AGREE=\"$BUILD_SCAN_TERMS_OF_SERVICE_AGREE\"" >> setenv.sh
chmod +x setenv.sh
- uses: education/autograding@v1
# Kills the running emulator on the default port
- name: Kill Emulator
if: always()
run: ./.github/scripts/stop_emulators.sh