Skip to content

Commit 27419f0

Browse files
authored
Merge pull request #7583 from vector-im/feature/bma/remove_buidkite
Remove usage of Buildkite.
2 parents 035b1eb + 492e842 commit 27419f0

File tree

22 files changed

+342
-53
lines changed

22 files changed

+342
-53
lines changed

CONTRIBUTING.md

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [Code quality](#code-quality)
1414
* [Internal tool](#internal-tool)
1515
* [ktlint](#ktlint)
16+
* [knit](#knit)
1617
* [lint](#lint)
1718
* [Unit tests](#unit-tests)
1819
* [Tests](#tests)
@@ -126,6 +127,23 @@ Note that you can run
126127

127128
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)
128129

130+
#### knit
131+
132+
[knit](https://github.com/Kotlin/kotlinx-knit) is a tool which checks markdown files on the project. Also it generates/updates the table of content (toc) of the markdown files.
133+
134+
So everytime the toc should be updated, just run
135+
<pre>
136+
./gradlew knit
137+
</pre>
138+
139+
and commit the changes.
140+
141+
The CI will check that markdown files are up to date by running
142+
143+
<pre>
144+
./gradlew knitCheck
145+
</pre>
146+
129147
#### lint
130148

131149
<pre>

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Buildkite](https://badge.buildkite.com/ad0065c1b70f557cd3b1d3d68f9c2154010f83c4d6f71706a9.svg?branch=develop)](https://buildkite.com/matrix-dot-org/element-android/builds?branch=develop)
1+
[![Latest build](https://github.com/vector-im/element-android/actions/workflows/build.yml/badge.svg?query=branch%3Adevelop)](https://github.com/vector-im/element-android/actions/workflows/build.yml?query=branch%3Adevelop)
22
[![Weblate](https://translate.element.io/widgets/element-android/-/svg-badge.svg)](https://translate.element.io/engage/element-android/?utm_source=widget)
33
[![Element Android Matrix room #element-android:matrix.org](https://img.shields.io/matrix/element-android:matrix.org.svg?label=%23element-android:matrix.org&logo=matrix&server_fqdn=matrix.org)](https://matrix.to/#/#element-android:matrix.org)
44
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vector-im_element-android&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vector-im_element-android)
@@ -14,7 +14,7 @@ It is a total rewrite of [Riot-Android](https://github.com/vector-im/riot-androi
1414
[<img src="resources/img/google-play-badge.png" alt="Get it on Google Play" height="60">](https://play.google.com/store/apps/details?id=im.vector.app)
1515
[<img src="resources/img/f-droid-badge.png" alt="Get it on F-Droid" height="60">](https://f-droid.org/app/im.vector.app)
1616

17-
Nightly build: [![Buildkite](https://badge.buildkite.com/ad0065c1b70f557cd3b1d3d68f9c2154010f83c4d6f71706a9.svg?branch=develop)](https://buildkite.com/matrix-dot-org/element-android/builds?branch=develop) Nightly test status: [![allScreensTest](https://github.com/vector-im/element-android/actions/workflows/nightly.yml/badge.svg)](https://github.com/vector-im/element-android/actions/workflows/nightly.yml)
17+
Build of develop branch: [![GitHub Action](https://github.com/vector-im/element-android/actions/workflows/build.yml/badge.svg?query=branch%3Adevelop)](https://github.com/vector-im/element-android/actions/workflows/build.yml?query=branch%3Adevelop) Nightly test status: [![allScreensTest](https://github.com/vector-im/element-android/actions/workflows/nightly.yml/badge.svg)](https://github.com/vector-im/element-android/actions/workflows/nightly.yml)
1818

1919

2020
# New Android SDK
@@ -40,7 +40,7 @@ If you would like to receive releases more quickly (bearing in mind that they ma
4040

4141
1. [Sign up to receive beta releases](https://play.google.com/apps/testing/im.vector.app) via the Google Play Store.
4242
2. Install a [release APK](https://github.com/vector-im/element-android/releases) directly - download the relevant .apk file and allow installing from untrusted sources in your device settings. Note: these releases are the Google Play version, which depend on some Google services. If you prefer to avoid that, try the latest dev builds, and choose the F-Droid version.
43-
3. If you're really brave, install the [very latest dev build](https://buildkite.com/matrix-dot-org/element-android/builds/latest?branch=develop&state=passed) - click on *Assemble (GPlay or FDroid) Debug version* then on *Artifacts*.
43+
3. If you're really brave, install the [very latest dev build](https://github.com/vector-im/element-android/actions/workflows/build.yml?query=branch%3Adevelop) - pick a build, then click on `Summary` to download the APKs from there: `vector-Fdroid-debug` and `vector-Gplay-debug` contains the APK for the desired store. Each file contains 5 APKs. 4 APKs for every supported specific architecture of device. In doubt you can install the `universal` APK.
4444

4545
## Contributing
4646

changelog.d/7583.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove usage of Buildkite.

docs/installing_from_ci.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Installing from CI
2+
3+
<!--- TOC -->
4+
5+
* [Installing from Buildkite](#installing-from-buildkite)
6+
* [Installing from GitHub](#installing-from-github)
7+
* [Create a GitHub token](#create-a-github-token)
8+
* [Provide artifact URL](#provide-artifact-url)
9+
* [Next steps](#next-steps)
10+
* [Future improvement](#future-improvement)
11+
12+
<!--- END -->
13+
14+
Installing APK build by the CI is possible
15+
16+
### Installing from Buildkite
17+
18+
The script `./tools/install/installFromBuildkite.sh` can be used, but Builkite will be removed soon. See next section.
19+
20+
### Installing from GitHub
21+
22+
To install an APK built by a GitHub action, run the script `./tools/install/installFromGitHub.sh`. You will need to pass a GitHub token to do so.
23+
24+
#### Create a GitHub token
25+
26+
You can create a GitHub token going to your Github account, at this page: [https://github.com/settings/tokens](https://github.com/settings/tokens).
27+
28+
You need to create a token (classic) with the scope `repo/public_repo`. So just check the corresponding checkbox.
29+
Validity can be long since the scope of this token is limited. You will still be able to delete the token and generate a new one.
30+
Click on Generate token and save the token locally.
31+
32+
### Provide artifact URL
33+
34+
The script will ask for an artifact URL. You can get this artifact URL by following these steps:
35+
36+
- open the pull request
37+
- in the check at the bottom, click on `APK Build / Build debug APKs`
38+
- click on `Summary`
39+
- scroll to the bottom of the page
40+
- copy the link `vector-Fdroid-debug` if you want the F-Droid variant or `vector-Gplay-debug` if you want the Gplay variant.
41+
42+
The copied link can be provided to the script.
43+
44+
### Next steps
45+
46+
The script will download the artifact, unzip it and install the correct version (regarding arch) on your device.
47+
48+
Files will be added to the folder `./tmp/DebugApks`. Feel free to cleanup this folder from time to time, the script will not delete files.
49+
50+
### Future improvement
51+
52+
The script could ask the user for a Pull Request number and Gplay/Fdroid choice like it was done with Buildkite script. Using GitHub API may be possible to do that.

tools/gradle/doctor.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Default configuration copied from https://runningcode.github.io/gradle-doctor/configuration/
22

3-
def isCiBuild = System.env.BUILDKITE == "true" || System.env.GITHUB_ACTIONS == "true"
3+
def isCiBuild = System.env.GITHUB_ACTIONS == "true"
44
println "Is CI build: $isCiBuild"
55

66
doctor {

tools/install/installFromGitHub.sh

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
if [[ "$#" -ne 1 ]]; then
7+
echo "Usage: $0 GitHub_Token" >&2
8+
echo "Read more about this script in the doc ./docs/installing_from_ci.md"
9+
exit 1
10+
fi
11+
12+
gitHubToken=$1
13+
14+
# Path where the app is cloned (it's where this project has been cloned)
15+
appPath=$(dirname $(dirname $(dirname $0)))
16+
# Path where the APK will be downloaded from CI (it's a dir)
17+
baseImportPath="${appPath}/tmp/DebugApks"
18+
19+
# Select device
20+
serialNumber=$(${appPath}/tools/install/androidSelectDevice.sh)
21+
22+
# Detect device architecture
23+
arch=$(adb -s ${serialNumber} shell getprop ro.product.cpu.abi)
24+
25+
echo
26+
echo "Will install the application on device ${serialNumber} with arch ${arch}"
27+
28+
# Artifact URL
29+
echo
30+
read -p "Artifact url (ex: https://github.com/vector-im/element-android/suites/9293388174/artifacts/435942121)? " artifactUrl
31+
32+
## Example of default value for Gplay
33+
#artifactUrl=${artifactUrl:-https://github.com/vector-im/element-android/suites/9293388174/artifacts/435942121}
34+
## Example of default value for FDroid
35+
# artifactUrl=${artifactUrl:-https://github.com/vector-im/element-android/suites/9293388174/artifacts/435942119}
36+
37+
artifactId=$(echo ${artifactUrl} | rev | cut -d'/' -f1 | rev)
38+
39+
# Download files
40+
targetPath=${baseImportPath}/${artifactId}
41+
42+
filename="artifact.zip"
43+
44+
fullFilePath="${targetPath}/${filename}"
45+
46+
# Check if file already exists
47+
if test -f "$fullFilePath"; then
48+
read -p "$fullFilePath already exists. Override (yes/no) default to no ? " download
49+
download=${download:-no}
50+
else
51+
download="yes"
52+
fi
53+
54+
# Ignore error from now
55+
set +e
56+
57+
if [ ${download} == "yes" ]; then
58+
echo "Downloading ${filename} to ${targetPath}..."
59+
python3 ${appPath}/tools/release/download_github_artifacts.py \
60+
--token ${gitHubToken} \
61+
--artifactUrl ${artifactUrl} \
62+
--directory ${targetPath} \
63+
--filename ${filename} \
64+
--ignoreErrors
65+
fi
66+
67+
echo "Unzipping ${filename}..."
68+
unzip $fullFilePath -d ${targetPath}
69+
70+
## gplay or fdroid
71+
if test -d "${targetPath}/gplay"; then
72+
variant="gplay"
73+
elif test -d "${targetPath}/fdroid"; then
74+
variant="fdroid"
75+
else
76+
echo "No variant found"
77+
exit 1
78+
fi
79+
80+
fullApkPath="${targetPath}/${variant}/debug/vector-${variant}-${arch}-debug.apk"
81+
82+
echo "Installing ${fullApkPath} to device ${serialNumber}..."
83+
adb -s ${serialNumber} install -r ${fullApkPath}
84+
85+
# Check error and propose to uninstall and retry installing
86+
if [[ "$?" -ne 0 ]]; then
87+
read -p "Error, do you want to uninstall the application then retry (yes/no) default to no ? " retry
88+
retry=${retry:-no}
89+
if [ ${retry} == "yes" ]; then
90+
echo "Uninstalling..."
91+
adb -s ${serialNumber} uninstall im.vector.app.debug
92+
echo "Installing again..."
93+
adb -s ${serialNumber} install -r ${fullApkPath}
94+
fi
95+
fi
+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2022 New Vector Ltd
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
import argparse
19+
import hashlib
20+
import json
21+
import os
22+
# Run `pip3 install requests` if not installed yet
23+
import requests
24+
25+
# This script downloads artifacts from GitHub.
26+
# Ref: https://docs.github.com/en/rest/actions/artifacts#get-an-artifact
27+
28+
error = False
29+
30+
### Arguments
31+
32+
parser = argparse.ArgumentParser(description='Download artifacts from GitHub.')
33+
parser.add_argument('-t',
34+
'--token',
35+
required=True,
36+
help='The GitHub token with read access.')
37+
parser.add_argument('-a',
38+
'--artifactUrl',
39+
required=True,
40+
help='the artifact_url from GitHub.')
41+
parser.add_argument('-f',
42+
'--filename',
43+
help='the filename, if not provided, will use the artifact name.')
44+
parser.add_argument('-i',
45+
'--ignoreErrors',
46+
help='Ignore errors that can be ignored. Build state and number of artifacts.',
47+
action="store_true")
48+
parser.add_argument('-d',
49+
'--directory',
50+
default="",
51+
help='the target directory, where files will be downloaded. If not provided the build number will be used to create a directory.')
52+
parser.add_argument('-v',
53+
'--verbose',
54+
help="increase output verbosity.",
55+
action="store_true")
56+
parser.add_argument('-s',
57+
'--simulate',
58+
help="simulate action, do not create folder or download any file.",
59+
action="store_true")
60+
61+
args = parser.parse_args()
62+
63+
if args.verbose:
64+
print("Argument:")
65+
print(args)
66+
67+
# Split the artifact URL to get information
68+
# Ex: https://github.com/vector-im/element-android/suites/9293388174/artifacts/435942121
69+
artifactUrl = args.artifactUrl
70+
if not artifactUrl.startswith('https://github.com/'):
71+
print("❌ Invalid parameter --artifactUrl %s. Must start with 'https://github.com/'" % artifactUrl)
72+
exit(1)
73+
if "/artifacts/" not in artifactUrl:
74+
print("❌ Invalid parameter --artifactUrl %s. Must contain '/artifacts/'" % artifactUrl)
75+
exit(1)
76+
artifactItems = artifactUrl.split("/")
77+
if len(artifactItems) != 9:
78+
print("❌ Invalid parameter --artifactUrl %s. Please check the format." % (artifactUrl))
79+
exit(1)
80+
81+
gitHubRepoOwner = artifactItems[3]
82+
gitHubRepo = artifactItems[4]
83+
artifactId = artifactItems[8]
84+
85+
if args.verbose:
86+
print("gitHubRepoOwner: %s, gitHubRepo: %s, artifactId: %s" % (gitHubRepoOwner, gitHubRepo, artifactId))
87+
88+
headers = {
89+
'Authorization': "Bearer %s" % args.token,
90+
'Accept': 'application/vnd.github+json'
91+
}
92+
base_url = "https://api.github.com/repos/%s/%s/actions/artifacts/%s" % (gitHubRepoOwner, gitHubRepo, artifactId)
93+
94+
### Fetch build state
95+
96+
print("Getting artifacts data of project '%s/%s' artifactId '%s'..." % (gitHubRepoOwner, gitHubRepo, artifactId))
97+
98+
if args.verbose:
99+
print("Url: %s" % base_url)
100+
101+
r = requests.get(base_url, headers=headers)
102+
data = json.loads(r.content.decode())
103+
104+
if args.verbose:
105+
print("Json data:")
106+
print(data)
107+
108+
if args.verbose:
109+
print("Create subfolder %s to download artifacts..." % artifactId)
110+
111+
if args.directory == "":
112+
targetDir = artifactId
113+
else:
114+
targetDir = args.directory
115+
116+
if not args.simulate:
117+
os.makedirs(targetDir, exist_ok=True)
118+
119+
url = data.get("archive_download_url")
120+
if args.filename is not None:
121+
filename = args.filename
122+
else:
123+
filename = data.get("name") + ".zip"
124+
125+
## Print some info about the artifact origin
126+
commitLink = "https://github.com/%s/%s/commit/%s" % (gitHubRepoOwner, gitHubRepo, data.get("workflow_run").get("head_sha"))
127+
print("Preparing to download artifact `%s`, built from branch: `%s` (commit %s)" % (data.get("name"), data.get("workflow_run").get("head_branch"), commitLink))
128+
129+
if args.verbose:
130+
print()
131+
print("Artifact url: %s" % url)
132+
133+
target = targetDir + "/" + filename
134+
sizeInBytes = data.get("size_in_bytes")
135+
print("Downloading %s to '%s' (file size is %s bytes, this may take a while)..." % (filename, targetDir, sizeInBytes))
136+
if not args.simulate:
137+
# open file to write in binary mode
138+
with open(target, "wb") as file:
139+
# get request
140+
response = requests.get(url, headers=headers)
141+
# write to file
142+
file.write(response.content)
143+
print("Verifying file size...")
144+
# get the file size
145+
size = os.path.getsize(target)
146+
if sizeInBytes != size:
147+
# error = True
148+
print("Warning, file size mismatch: expecting %s and get %s. This is just a warning for now..." % (sizeInBytes, size))
149+
150+
if error:
151+
print("❌ Error(s) occurred, please check the log")
152+
exit(1)
153+
else:
154+
print("Done!")

tools/release/releaseScript.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ else
214214
fi
215215

216216
printf "\n================================================================================\n"
217-
read -p "Wait for Buildkite https://buildkite.com/matrix-dot-org/element-android/builds?branch=main to build the 'main' branch. Press enter when it's done."
217+
read -p "Wait for the GitHub action https://github.com/vector-im/element-android/actions/workflows/build.yml?query=branch%3Amain to build the 'main' branch. Press enter when it's done."
218218

219219
printf "\n================================================================================\n"
220220
printf "Running the release script...\n"

0 commit comments

Comments
 (0)