Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use selfhosted S3 build cache #724

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d7e41c6
Setup S3 build cache
chippmann Oct 9, 2024
4d08e30
Inherit secrets
chippmann Oct 9, 2024
01eaf38
Reference secrets
chippmann Oct 9, 2024
8306567
Fix action reference
chippmann Oct 9, 2024
9254bb2
Create custom action for S3 caching
chippmann Oct 9, 2024
721b001
Revert "Create custom action for S3 caching"
chippmann Oct 9, 2024
a3a1204
Use up to date fork of original action
chippmann Oct 9, 2024
40cd3e5
Use maintained fork
chippmann Oct 9, 2024
ccce4ce
Fix cache step checks
chippmann Oct 9, 2024
dd2b888
Fix cache step checks
chippmann Oct 9, 2024
115b3d2
Add log
chippmann Oct 9, 2024
62ff3c4
Use inherited secrets instead
chippmann Oct 9, 2024
baeaf2d
Setup new custom action which is more generic
chippmann Oct 9, 2024
e441b9d
Improve workflow setup so that each target gets truly its own cache
chippmann Oct 9, 2024
b2983e2
Implement cleanup
chippmann Oct 9, 2024
a609767
Rename trigger workflow and add todo to convert it to tier setup of m…
chippmann Oct 9, 2024
b2d5160
Cleanup ubuntu os version used for actions
chippmann Oct 9, 2024
032a585
Improve setup and caching of jvm builds
chippmann Oct 9, 2024
49c1e30
Build idea plugin zip again
chippmann Oct 9, 2024
a1b7405
Replace slashes in ref with underscores to prevent the creation of ne…
chippmann Oct 9, 2024
ac876dc
Let jvm build also inherit secrets
chippmann Oct 9, 2024
7b945c7
Add missing input variable
chippmann Oct 10, 2024
2a2894d
Improve workflow setup for tests and improve gradle cache setup
chippmann Oct 10, 2024
1f0bc03
Update action `github-script`
chippmann Oct 10, 2024
9e14760
Let test actions inherit secrets
chippmann Oct 10, 2024
1a7d6f6
Do not use latest os for godot builds
chippmann Oct 10, 2024
2d5ef34
Fix download path of editor executable
chippmann Oct 10, 2024
39b0a35
Fix change dir call
chippmann Oct 10, 2024
29df707
Enable PR checks for regular branch builds to test them
chippmann Oct 10, 2024
ef00210
Remove env reference
chippmann Oct 10, 2024
47b0ea2
Use latest again for macos build because of vulkan
chippmann Oct 10, 2024
aa56aae
Explicitly use 14
chippmann Oct 10, 2024
5967d79
Setup vulkan in a safe way until fixed in godot
chippmann Oct 10, 2024
f7df022
Use master in readonly mode on a cache miss
chippmann Oct 10, 2024
6c530cd
Pass missing param for assemble android
chippmann Oct 10, 2024
151c354
Fix cache hit check
chippmann Oct 10, 2024
e365e5b
Setup scons for android export template assembly
chippmann Oct 10, 2024
ff5955a
Disable running pr tests on every branch which was enabled for testing
chippmann Oct 10, 2024
2ee462a
Fix cache hit check
chippmann Oct 10, 2024
e5dd102
Add comment to explain master cache copy on cache miss
chippmann Oct 10, 2024
2230e83
Use temurin instead of adopt to test connectivity issues
chippmann Oct 10, 2024
d3f59cf
Use temurin as jdk distribution
chippmann Oct 10, 2024
463a2a3
Fix worklfow name
chippmann Oct 10, 2024
42bce8f
Test cleanup
chippmann Oct 10, 2024
4ea2bc5
Add moltenvk cache
chippmann Oct 10, 2024
c990ef2
Fix cleanup alias
chippmann Oct 10, 2024
28e9d5f
Filter out listings named STANDARD
chippmann Oct 10, 2024
d38cccd
Add cleanup log
chippmann Oct 10, 2024
e3bca17
Only do cleanup on master again
chippmann Oct 10, 2024
e7499bc
Run PR checks on branch again to test moltenvk cache
chippmann Oct 10, 2024
4e8a935
Clone our module for our custom cache action
chippmann Oct 10, 2024
2d05f15
Inherit secrets
chippmann Oct 10, 2024
4660a5a
Fix ios moltenvk cache name
chippmann Oct 11, 2024
2c6a089
Setup java home using already setup java versions on the runners
chippmann Oct 11, 2024
f454806
Fix java home assignment
chippmann Oct 11, 2024
82634a7
Fix run indent
chippmann Oct 11, 2024
0f54ca3
Log java home
chippmann Oct 11, 2024
34d6206
Run on pull requests only again
chippmann Oct 11, 2024
76ce680
Inherit secrets for assemble ios
chippmann Oct 11, 2024
fb15f28
Revert "Run on pull requests only again"
chippmann Oct 11, 2024
428e14f
Manually reference jlink
chippmann Oct 12, 2024
6a52c83
Revert "Manually reference jlink"
chippmann Oct 12, 2024
2b31698
Revert "Log java home"
chippmann Oct 12, 2024
ae9d105
Revert "Fix run indent"
chippmann Oct 12, 2024
95652e1
Revert "Fix java home assignment"
chippmann Oct 12, 2024
4d5092f
Revert "Setup java home using already setup java versions on the runn…
chippmann Oct 12, 2024
4738ad7
Reapply "Run on pull requests only again"
chippmann Oct 12, 2024
ff56cdf
Use base branch ref for PR's
chippmann Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@

name: Setup build cache
description: Setup build cache using a self-hosted S3 instance if in our repo, or github cache if on a fork.
inputs:
key:
description: The cache base key (job name by default). Gets suffixed by the current git ref
default: "${{github.job}}"
path:
description: The cache path.
s3-user:
description: Username of self-hosted s3
s3-password:
description: Password of self-hosted s3
s3-user-readonly:
description: Readonly username of self-hosted s3
s3-password-readonly:
description: Readonly password of self-hosted s3
s3-host:
description: Host of self-hosted s3
s3-bucket:
description: Bucket of self-hosted s3

runs:
using: "composite"
steps:
# ==================================================================================================================
# S3 cache setup
# ==================================================================================================================
#
# Cache setup for our own repo
# Stores the cache on a self-hosted S3 instance based on cache name and suffixed by the git ref
# example: editor_debug_linux_x86_64-refs_heads_master

- name: Prepare GitHub ref
if: ${{ inputs.s3-host != '' }}
id: prepare_ref
uses: actions/[email protected]
with:
script: |
let branch = '';
// Check if it is a PR
if (process.env.GITHUB_HEAD_REF) {
branch = process.env.GITHUB_HEAD_REF.replace(/\//g, '_'); // Use head ref for PRs
} else {
branch = process.env.GITHUB_REF.split('/').slice(2).join('_'); // Standard ref
}
core.exportVariable('PREPARED_REF', branch);

- name: Setup s3 cache
id: cache_setup
if: ${{ inputs.s3-host != '' }}
uses: philiplehmann/[email protected]
with:
endpoint: ${{inputs.s3-host}} # optional, default s3.amazonaws.com
port: 443 # minio port
insecure: false # optional, use http instead of https. default false
accessKey: ${{inputs.s3-user}} # required
secretKey: ${{inputs.s3-password}} # required
bucket: ${{inputs.s3-bucket}} # required
key: ${{ inputs.key }}-${{ env.PREPARED_REF }}
path: ${{ inputs.path }}

- name: Use master cache if specific cache was missed
# if we got no cache hit, this means we do not yet have a cache for this git ref
# hence we restore the cache from master with readonly S3 credentials
# this basically allows us to reuse the cache from master, do our compilation and "copy" that to the git ref
# specific cache and because the credentials are read only, we do not override the master cache in the end
if: steps.cache_setup.outputs.cache-hit != 'true'
uses: philiplehmann/[email protected]
with:
endpoint: ${{inputs.s3-host}}
port: 443
insecure: false
accessKey: ${{inputs.s3-user-readonly}}
secretKey: ${{inputs.s3-password-readonly}}
bucket: ${{inputs.s3-bucket}}
key: ${{ inputs.key }}-refs_heads_master # use master cache readonly if no cache hit
path: ${{ inputs.path }}
continue-on-error: true

# ==================================================================================================================
# fork cache setup
# ==================================================================================================================
#
# Cache setup for forks or pull requests from forks
# Stores the cache on github hosted caches


# Upload cache on completion and check it out now
- name: Load .scons_cache directory
if: ${{ github.ref == 'refs/heads/master' && inputs.s3-host == '' }}
uses: actions/cache@v4
with:
path: ${{inputs.path}}
key: ${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}

# We try to match an existing cache to restore from it. Each potential key is checked against
# all existing caches as a prefix. E.g. 'linux-template-minimal' would match any cache that
# starts with "linux-template-minimal", such as "linux-template-minimal-master-refs/heads/master-6588a4a29af1621086feac0117d5d4d37af957fd".
#
# We check these prefixes in this order:
#
# 1. The exact match, including the base branch, the commit reference, and the SHA hash of the commit.
# 2. A partial match for the same base branch and the same commit reference.
# 3. A partial match for the same base branch and the base branch commit reference.
# 4. A partial match for the same base branch only (not ideal, matches any PR with the same base branch).

restore-keys: |
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-refs/heads/${{env.GODOT_BASE_BRANCH}}
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}

# Check out cache but do not upload it at the end
- name: Load .scons_cache directory
if: ${{ github.ref != 'refs/heads/master' && inputs.s3-host == '' }}
uses: actions/cache/restore@v4 # only restores the cache but does not upload it
with:
path: ${{inputs.path}}
key: ${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}

# We try to match an existing cache to restore from it. Each potential key is checked against
# all existing caches as a prefix. E.g. 'linux-template-minimal' would match any cache that
# starts with "linux-template-minimal", such as "linux-template-minimal-master-refs/heads/master-6588a4a29af1621086feac0117d5d4d37af957fd".
#
# We check these prefixes in this order:
#
# 1. The exact match, including the base branch, the commit reference, and the SHA hash of the commit.
# 2. A partial match for the same base branch and the same commit reference.
# 3. A partial match for the same base branch and the base branch commit reference.
# 4. A partial match for the same base branch only (not ideal, matches any PR with the same base branch).

restore-keys: |
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}-refs/heads/${{env.GODOT_BASE_BRANCH}}
${{inputs.key}}-${{env.GODOT_BASE_BRANCH}}

65 changes: 0 additions & 65 deletions .github/actions/scons-cache/action.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/assemble_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: 🤖 Assemble Android
on:
workflow_call:
inputs:
godot-version:
type: string
jvm-version:
type: string

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux_assemble
cancel-in-progress: true

jobs:
create-android-export-template:
runs-on: ubuntu-latest
name: ${{ matrix.name }}
steps:
- name: Maximize build space
uses: AdityaGarg8/[email protected]
with:
remove-dotnet: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
remove-swapfile: 'true'

- name: Clone Godot Engine
uses: actions/checkout@v4
with:
repository: godotengine/godot
ref: ${{ inputs.godot-version }}

- name: Clone Godot JVM module.
uses: actions/checkout@v4
with:
path: modules/kotlin_jvm

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ inputs.jvm-version }}

- name: Setup python and scons
uses: ./.github/actions/godot-deps

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/master' }}

- name: Download android libs release arm32
uses: actions/download-artifact@v4
with:
name: export_template_release_android_arm32
path: "platform/android/java/lib/libs/"

- name: Download android libs debug arm32
uses: actions/download-artifact@v4
with:
name: export_template_debug_android_arm32
path: "platform/android/java/lib/libs/"

- name: Download android libs release arm64
uses: actions/download-artifact@v4
with:
name: export_template_release_android_arm64
path: "platform/android/java/lib/libs/"

- name: Download android libs debug arm64
uses: actions/download-artifact@v4
with:
name: export_template_debug_android_arm64
path: "platform/android/java/lib/libs/"

- name: Download android libs release x86_64
uses: actions/download-artifact@v4
with:
name: export_template_release_android_x86_64
path: "platform/android/java/lib/libs/"

- name: Download android libs debug x86_64
uses: actions/download-artifact@v4
with:
name: export_template_debug_android_x86_64
path: "platform/android/java/lib/libs/"

- name: Generate Godot templates
run: |
ls -l platform/android/java/lib/libs/
cd platform/android/java
./gradlew generateGodotTemplates
cd ../../..
ls -l bin/

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: export_template_android_all
path: "bin/*"
2 changes: 1 addition & 1 deletion .github/workflows/assemble_export_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:

jobs:
create-export-templates-tpz:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
name: Create export template tpz
steps:
- name: Create templates folder
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/assemble_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,52 @@ jobs:
repository: godotengine/godot
ref: ${{ inputs.godot-version }}

- name: Clone Godot JVM module.
uses: actions/checkout@v4
with:
path: modules/kotlin_jvm

# Python must be kept below 3.12
#https://github.com/KhronosGroup/MoltenVK/blob/3b9e335fe8fc8a72cf6099acbd54128889445c0a/.github/workflows/CI.yml#L44
- name: Setup python and scons
uses: ./.github/actions/godot-deps
with:
python-version: 3.11

- name: Download ios export template binaries
- name: Download ios export template binaries debug
uses: actions/download-artifact@v4
with:
name: export_template_ios_all
name: export_template_debug_ios_arm64
path: "./"

- name: Download ios export template binaries release
uses: actions/download-artifact@v4
with:
name: export_template_release_ios_arm64
path: "./"

- name: Setup MoltenVK build cache
uses: ./modules/kotlin_jvm/.github/actions/cache
with:
key: assemble_ios_moltenvk_cache
path: |
MoltenVk/Package
MoltenVk/External
MoltenVk/xcuserdata
MoltenVk/project.xcworkspace
MoltenVk/*.xccheckout
MoltenVk/*.xcscmblueprint
MoltenVk/build
MoltenVk/*.o
MoltenVk/*.a
s3-host: ${{ secrets.S3_HOST }}
s3-bucket: ${{ secrets.S3_BUCKET }}
s3-user: ${{ secrets.S3_USER }}
s3-password: ${{ secrets.S3_PASSWORD }}
s3-user-readonly: ${{ secrets.S3_USER_READONLY }}
s3-password-readonly: ${{ secrets.S3_PASSWORD_READONLY }}
continue-on-error: true

- name: Clone MoltenVK
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/assemble_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:

jobs:
create-linux-editor-zip:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand Down
Loading
Loading