This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
135 lines (118 loc) · 4.96 KB
/
classroom_hosted.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
name: GitHub Classroom Workflow self-hosted
on:
- 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: "sample/application"
README_PATH: "sample"
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: enetcom-cr
container:
image: ghcr.io/khammami/containers/ubnutu-jdk17-android34:latest
options: --privileged
env:
ANDROID_HOME: /android-sdk
ANDROID_AVD_HOME: /root/.android/avd
if: github.actor != 'github-classroom[bot]'
needs: [check-android-project]
steps:
# Get the code
- uses: actions/checkout@v4
- name: Make all scripts executable
run: |
find .github/scripts -type f -name "*.sh" -exec chmod +x {} \;
chmod +x ${{env.ANDROID_APP_PATH}}/gradlew
# 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-service-url: "https://gradle.com/terms-of-service"
build-scan-terms-of-service-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_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'
# timeout-minutes: 5
# run: |
# printenv
# ./.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: 5
run: ./.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