From 8e444e892019ba3619687e4a89763ae4a2206839 Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 14 Nov 2024 20:18:30 +0300 Subject: [PATCH 1/5] Run test_all instead of test_image via OS specific workflows Instead of running test_image directly via OS specific workflows running test_all in between. Reason of that change is being able to run purpose specific tests as separate jobs easily. It is a preperation commit for cache tests. --- .github/workflows/test_2004.yml | 2 +- .github/workflows/test_2204.yml | 2 +- .github/workflows/test_2404.yml | 2 +- .github/workflows/test_all.yml | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test_all.yml diff --git a/.github/workflows/test_2004.yml b/.github/workflows/test_2004.yml index dbe9cde..71c2177 100644 --- a/.github/workflows/test_2004.yml +++ b/.github/workflows/test_2004.yml @@ -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 diff --git a/.github/workflows/test_2204.yml b/.github/workflows/test_2204.yml index d08dcd6..fb9cefd 100644 --- a/.github/workflows/test_2204.yml +++ b/.github/workflows/test_2204.yml @@ -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 diff --git a/.github/workflows/test_2404.yml b/.github/workflows/test_2404.yml index 7f380be..e695592 100644 --- a/.github/workflows/test_2404.yml +++ b/.github/workflows/test_2404.yml @@ -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 diff --git a/.github/workflows/test_all.yml b/.github/workflows/test_all.yml new file mode 100644 index 0000000..8512824 --- /dev/null +++ b/.github/workflows/test_all.yml @@ -0,0 +1,22 @@ +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 }} \ No newline at end of file From 38a4c4eb3d9c9633cbdbefd9a84b6000f2a20b9b Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 14 Nov 2024 20:22:51 +0300 Subject: [PATCH 2/5] Add first cache tests - python cache Adding cache tests for python. Since it is the first cache test, adjusting workflows accordingly as well. - New jobs are added to all tests. Restore depends on the save - test_restore_cache and test_restore_save workflows are added - python folder added with requirements.txt to use python cache --- .github/workflows/test_all.yml | 17 +++++++++++++- .github/workflows/test_image.yml | 2 +- .github/workflows/test_restore_cache.yml | 30 ++++++++++++++++++++++++ .github/workflows/test_save_cache.yml | 30 ++++++++++++++++++++++++ python/requirements.txt | 2 ++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test_restore_cache.yml create mode 100644 .github/workflows/test_save_cache.yml create mode 100644 python/requirements.txt diff --git a/.github/workflows/test_all.yml b/.github/workflows/test_all.yml index 8512824..b7a6b32 100644 --- a/.github/workflows/test_all.yml +++ b/.github/workflows/test_all.yml @@ -19,4 +19,19 @@ jobs: with: runner: ${{ inputs.runner }} image_os: ${{ inputs.image_os }} - arch: ${{ inputs.arch }} \ No newline at end of file + 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 }} diff --git a/.github/workflows/test_image.yml b/.github/workflows/test_image.yml index 64e0aef..50e4dae 100644 --- a/.github/workflows/test_image.yml +++ b/.github/workflows/test_image.yml @@ -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 diff --git a/.github/workflows/test_restore_cache.yml b/.github/workflows/test_restore_cache.yml new file mode 100644 index 0000000..895abe0 --- /dev/null +++ b/.github/workflows/test_restore_cache.yml @@ -0,0 +1,30 @@ +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: + 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 diff --git a/.github/workflows/test_save_cache.yml b/.github/workflows/test_save_cache.yml new file mode 100644 index 0000000..a39f805 --- /dev/null +++ b/.github/workflows/test_save_cache.yml @@ -0,0 +1,30 @@ +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: + 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 diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..5b22892 --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,2 @@ +# Just a sample dependency to check caching work +requests==2.28.1 From 5db543947e387a04bd498aa1bf67e5e66878b3a7 Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 14 Nov 2024 20:26:44 +0300 Subject: [PATCH 3/5] Add golang cache tests Adding cache tests for the golang --- .github/workflows/test_restore_cache.yml | 5 +++++ .github/workflows/test_save_cache.yml | 5 +++++ go/go.sum | 3 +++ 3 files changed, 13 insertions(+) create mode 100644 go/go.sum diff --git a/.github/workflows/test_restore_cache.yml b/.github/workflows/test_restore_cache.yml index 895abe0..d04e915 100644 --- a/.github/workflows/test_restore_cache.yml +++ b/.github/workflows/test_restore_cache.yml @@ -28,3 +28,8 @@ jobs: 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 diff --git a/.github/workflows/test_save_cache.yml b/.github/workflows/test_save_cache.yml index a39f805..3b9005b 100644 --- a/.github/workflows/test_save_cache.yml +++ b/.github/workflows/test_save_cache.yml @@ -28,3 +28,8 @@ jobs: 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 diff --git a/go/go.sum b/go/go.sum new file mode 100644 index 0000000..ac2c6e6 --- /dev/null +++ b/go/go.sum @@ -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= \ No newline at end of file From a932e8f2a78f07806a3d4697d656c0a4f95c56ac Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 14 Nov 2024 20:29:46 +0300 Subject: [PATCH 4/5] Add ruby cache tests Adding cache tests for the ruby --- .github/workflows/test_restore_cache.yml | 9 +++++++++ .github/workflows/test_save_cache.yml | 9 +++++++++ ruby/Gemfile | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 ruby/Gemfile diff --git a/.github/workflows/test_restore_cache.yml b/.github/workflows/test_restore_cache.yml index d04e915..637b02e 100644 --- a/.github/workflows/test_restore_cache.yml +++ b/.github/workflows/test_restore_cache.yml @@ -15,6 +15,9 @@ on: jobs: test: + env: + BUNDLE_GEMFILE: ./ruby/Gemfile + name: ${{ inputs.image_os }} ${{ inputs.arch }} restore cache runs-on: ${{ inputs.runner }} steps: @@ -33,3 +36,9 @@ jobs: 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 diff --git a/.github/workflows/test_save_cache.yml b/.github/workflows/test_save_cache.yml index 3b9005b..9e5b71c 100644 --- a/.github/workflows/test_save_cache.yml +++ b/.github/workflows/test_save_cache.yml @@ -15,6 +15,9 @@ on: jobs: test: + env: + BUNDLE_GEMFILE: ./ruby/Gemfile + name: ${{ inputs.image_os }} ${{ inputs.arch }} save cache runs-on: ${{ inputs.runner }} steps: @@ -33,3 +36,9 @@ jobs: 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 diff --git a/ruby/Gemfile b/ruby/Gemfile new file mode 100644 index 0000000..4cdde54 --- /dev/null +++ b/ruby/Gemfile @@ -0,0 +1,5 @@ +# Just a sample dependency to check caching work +ruby "3.2.6" +source "https://rubygems.org" + +gem "sequel" From 57d7857ad67ff933d757a0ccaf26af5fdad457db Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 14 Nov 2024 20:30:58 +0300 Subject: [PATCH 5/5] Add tests for actions/cache action Testing direct file cache with actions/cache/save and actions/cache/restore --- .github/workflows/test_restore_cache.yml | 8 ++++++++ .github/workflows/test_save_cache.yml | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.github/workflows/test_restore_cache.yml b/.github/workflows/test_restore_cache.yml index 637b02e..bc40eb2 100644 --- a/.github/workflows/test_restore_cache.yml +++ b/.github/workflows/test_restore_cache.yml @@ -42,3 +42,11 @@ jobs: 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 diff --git a/.github/workflows/test_save_cache.yml b/.github/workflows/test_save_cache.yml index 9e5b71c..601c8d2 100644 --- a/.github/workflows/test_save_cache.yml +++ b/.github/workflows/test_save_cache.yml @@ -42,3 +42,18 @@ jobs: 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