This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
forked from Enet-Com-23/pfa-tp-2-1-template-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (133 loc) · 5.65 KB
/
classroom.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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