-
Notifications
You must be signed in to change notification settings - Fork 527
/
action.yml
89 lines (77 loc) · 3.01 KB
/
action.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
# Contains common operations to set up a hermetic Android + Bazel build environment for Oppia
# Android CI workflows. Action prerequisites:
# - JDK 11 must be installed & set as the default version via JAVA_HOME
# - Bazel must be installed, in the path, and be version 6.5.0
# TODO(#1861): Revert SDK pinning for improved CI performance once Bazel is sufficiently stable that
# we can rely on the automatic SDK provided by GitHub's CI environment.
name: Build environment setup
description: Sets up the Android & Bazel build environments for Oppia Android
runs:
using: composite
steps:
- name: Check Java version & path
run: |
which java
java -version
echo "Java home: $JAVA_HOME"
$JAVA_HOME/bin/java -version
# Verify that the correct version of Java is installed.
java -version 2>&1 | grep -q -E "11.0"
HAS_CORRECT_JAVA_VERSION=$(echo $?)
if [[ "$HAS_CORRECT_JAVA_VERSION" == 1 ]] ; then
echo "Expected Java 11 to be installed"
exit 1
fi
shell: bash
- name: Verify Bazel version
run: |
bazel --version | grep -q 6.5.0
HAS_CORRECT_BAZEL_VERSION=$(echo $?)
if [[ "$HAS_CORRECT_JAVA_VERSION" == 1 ]] ; then
echo "Expected Bazel 6.5.0 to be installed"
exit 1
fi
shell: bash
- name: Set up new Android SDK directory
run: |
mkdir -p $HOME/android-sdk
shell: bash
- name: Download cmdline tools
run: |
wget https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip
cp ./commandlinetools-linux-7302050_latest.zip $HOME/android-sdk
cd $HOME/android-sdk
unzip commandlinetools-linux-7302050_latest.zip
mkdir tools
cd cmdline-tools/
mv -i * ../tools && mv ../tools .
cd ..
echo "ANDROID_HOME=$HOME/android-sdk" >> $GITHUB_ENV
shell: bash
- name: Verify updated ANDROID_HOME
run: |
echo "Using updated Android SDK home: $ANDROID_HOME"
shell: bash
- name: Accept SDK licenses
run: |
# For some reason, sdkmanager returns an error code when licenses are accepted. Run in a
# sub-shell so that the CI workflow doesn't fail.
echo $(yes | $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --licenses)
shell: bash
- name: Install platform tools
run: |
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platform-tools"
shell: bash
- name: Install SDK 33
run: |
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-33"
shell: bash
- name: Install build tools 32.0.0
run: |
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "build-tools;32.0.0"
shell: bash
- name: Configure Bazel to use specific sandbox tmpfs
run: |
echo "build --enable_platform_specific_config" >> $HOME/.bazelrc
echo "build:linux --sandbox_tmpfs_path=/tmp" >> $HOME/.bazelrc
shell: bash