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

Add cache tests #7

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test_2004.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
test_image:
uses: ./.github/workflows/test_image.yml
uses: ./.github/workflows/test_all.yml
with:
runner: ${{ inputs.arch == 'x64' && 'ubicloud-standard-2-ubuntu-2004' || 'ubicloud-standard-2-arm-ubuntu-2004' }}
image_os: ubuntu20
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_2204.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
test_image:
uses: ./.github/workflows/test_image.yml
uses: ./.github/workflows/test_all.yml
with:
runner: ${{ inputs.arch == 'x64' && 'ubicloud-standard-2-ubuntu-2204' || 'ubicloud-standard-2-arm-ubuntu-2204' }}
image_os: ubuntu22
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_2404.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
test_image:
uses: ./.github/workflows/test_image.yml
uses: ./.github/workflows/test_all.yml
with:
runner: ${{ inputs.arch == 'x64' && 'ubicloud-standard-2-ubuntu-2404' || 'ubicloud-standard-2-arm-ubuntu-2404' }}
image_os: ubuntu24
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/test_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test core functionality of image

on:
workflow_call:
inputs:
runner:
required: true
type: string
image_os:
required: true
type: string
arch:
required: true
type: string

jobs:
test_image:
uses: ./.github/workflows/test_image.yml
with:
runner: ${{ inputs.runner }}
image_os: ${{ inputs.image_os }}
arch: ${{ inputs.arch }}

test_save_cache:
uses: ./.github/workflows/test_save_cache.yml
with:
runner: ${{ inputs.runner }}
image_os: ${{ inputs.image_os }}
arch: ${{ inputs.arch }}

test_restore_cache:
needs: test_save_cache
uses: ./.github/workflows/test_restore_cache.yml
with:
runner: ${{ inputs.runner }}
image_os: ${{ inputs.image_os }}
arch: ${{ inputs.arch }}
2 changes: 1 addition & 1 deletion .github/workflows/test_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
EXPECTED_VARIABLE_COUNT: ${{ inputs.arch == 'x64' && 100 || 80 }}
EXPECTED_RUNNER_ARCH: ${{ inputs.arch == 'x64' && 'X64' || 'ARM64' }}
EXPECTED_ANDROID_HOME: ${{ inputs.arch == 'x64' && '/usr/local/lib/android/sdk' || '' }}
name: ${{ inputs.image_os }} ${{ inputs.arch }}
name: ${{ inputs.image_os }} ${{ inputs.arch }} core functionality
runs-on: ${{ inputs.runner }}
steps:
- name: Checkout code
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/test_restore_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test restore cache functionalities

on:
workflow_call:
inputs:
runner:
required: true
type: string
image_os:
required: true
type: string
arch:
required: true
type: string

jobs:
test:
env:
BUNDLE_GEMFILE: ./ruby/Gemfile

name: ${{ inputs.image_os }} ${{ inputs.arch }} restore cache
runs-on: ${{ inputs.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup python with cache
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'

- run: pip install -r python/requirements.txt

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache-dependency-path: go/go.sum

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.6'
bundler-cache: true

- name: Restore folders and files
uses: actions/cache/restore@v4
with:
path: |
myfolder
myfolder2
key: cached_folders
59 changes: 59 additions & 0 deletions .github/workflows/test_save_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test save cache functionalities

on:
workflow_call:
inputs:
runner:
required: true
type: string
image_os:
required: true
type: string
arch:
required: true
type: string

jobs:
test:
env:
BUNDLE_GEMFILE: ./ruby/Gemfile

name: ${{ inputs.image_os }} ${{ inputs.arch }} save cache
runs-on: ${{ inputs.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup python with cache
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'

- run: pip install -r python/requirements.txt

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache-dependency-path: go/go.sum

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.6'
bundler-cache: true

- name: Generate folders and files to cache
run: |
mkdir myfolder
dd if=/dev/urandom of=myfolder/file1.txt bs=1M count=100
mkdir myfolder2
dd if=/dev/urandom of=myfolder2/file1.txt bs=1M count=150

- name: Save folders and files
uses: actions/cache/save@v4
with:
path: |
myfolder
myfolder2
key: cached_folders
3 changes: 3 additions & 0 deletions go/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Just a sample dependency to check caching work
github.com/stretchr/testify v1.7.0 h1:1CDZFwtvdxnfPUEciY+TvuiwxAXoaK3P3UoNde6GKtU=
github.com/stretchr/testify v1.7.0/go.mod h1:FkQac1HR7MZ0cnMpGB7FZ5OIbL9G4yk6j9g9OR1MXT0=
2 changes: 2 additions & 0 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Just a sample dependency to check caching work
requests==2.28.1
5 changes: 5 additions & 0 deletions ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Just a sample dependency to check caching work
ruby "3.2.6"
source "https://rubygems.org"

gem "sequel"