From d12f47b1c317318abb9b35746edaadd3e04003d6 Mon Sep 17 00:00:00 2001 From: Robby Cochran Date: Thu, 12 Sep 2024 17:58:30 -0700 Subject: [PATCH] enable s390x caching --- .github/workflows/collector-builder.yml | 3 ++- .github/workflows/collector.yml | 6 ++++++ .gitignore | 1 + ansible/ci-build-builder.yml | 18 ++++++++++++++++++ ansible/ci-build-collector.yml | 18 ++++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/.github/workflows/collector-builder.yml b/.github/workflows/collector-builder.yml index e9ce46a249b..317b1154069 100644 --- a/.github/workflows/collector-builder.yml +++ b/.github/workflows/collector-builder.yml @@ -77,7 +77,7 @@ jobs: - name: Set up builder ccache uses: actions/cache@v3 with: - path: builder-ccache + path: {{ github.workspace }}/builder/.ccache key: builder-ccache-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}-${{ github.sha }} restore-keys: | builder-ccache-${{ matrix.arch }}- @@ -172,6 +172,7 @@ jobs: -i ansible/ci \ -e build_hosts='job_id_${{ env.JOB_ID }}' \ -e arch='${{ matrix.arch }}' \ + -e github_workspace='${{ github.workspace }}' \ -e @'${{ github.workspace }}/ansible/secrets.yml' \ ansible/ci-build-builder.yml diff --git a/.github/workflows/collector.yml b/.github/workflows/collector.yml index c9bace18ad6..e83fe5046df 100644 --- a/.github/workflows/collector.yml +++ b/.github/workflows/collector.yml @@ -128,6 +128,11 @@ jobs: vm-type: rhel-${{ matrix.arch }} job-tag: builder + - name: Set up ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ matrix.arch }} + - name: Create Build VMs run: | make -C "${{ github.workspace }}/ansible" create-build-vms @@ -157,6 +162,7 @@ jobs: -i ansible/ci \ -e arch='${{ matrix.arch }}' \ -e build_hosts='job_id_${{ env.JOB_ID }}' \ + -e github_workspace='${{ github.workspace }}' \ -e @'${{ github.workspace }}/ansible/secrets.yml' \ ansible/ci-build-collector.yml diff --git a/.gitignore b/.gitignore index 030541eb2ef..c6e4b82c24a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ .rox/ .ccache/ +builder/.ccache/ integration-tests/container-logs/ integration-tests/*.log diff --git a/ansible/ci-build-builder.yml b/ansible/ci-build-builder.yml index f70bba5066b..443338c6e24 100644 --- a/ansible/ci-build-builder.yml +++ b/ansible/ci-build-builder.yml @@ -10,6 +10,8 @@ vars: collector_root: "{{ ansible_env.HOME }}/collector" local_branch: local + local_ccache_dir: "{{ github_workspace }}/builder/.ccache" + remote_ccache_dir: "{{ collector_root }}/builder/.ccache" tasks: - name: Clone repository @@ -24,6 +26,15 @@ recursive: true when: arch == "s390x" + - name: Copy ccache to the remote machine + ansible.builtin.copy: + src: "{{ local_ccache_dir }}" + dest: "{{ remote_ccache_dir }}" + mode: preserve + remote_src: no + delegate_to: localhost + when: arch == "s390x" + - name: Build the collector builder image community.general.make: chdir: "{{ ansible_env.GITHUB_WORKSPACE | default(collector_root) }}" @@ -31,6 +42,13 @@ params: USE_CCACHE: "true" + - name: Copy ccache back to local machine + ansible.builtin.fetch: + src: "{{ remote_ccache_dir }}" + dest: "{{ local_ccache_dir }}" + flat: yes + when: arch == "s390x" + - name: Retag collector builder image to arch specific community.docker.docker_image: name: "quay.io/stackrox-io/collector-builder:{{ ansible_env.COLLECTOR_BUILDER_TAG }}" diff --git a/ansible/ci-build-collector.yml b/ansible/ci-build-collector.yml index d5830163620..0f268fad10a 100644 --- a/ansible/ci-build-collector.yml +++ b/ansible/ci-build-collector.yml @@ -12,6 +12,8 @@ vars: collector_root: "{{ ansible_env.HOME }}/collector" local_branch: local + local_ccache_dir: "{{ github_workspace }}/.ccache" + remote_ccache_dir: "{{ collector_root }}/.ccache" tasks: - debug: var=collector_root @@ -27,6 +29,15 @@ recursive: true when: arch == "s390x" + - name: Copy ccache to the remote machine + ansible.builtin.copy: + src: "{{ local_ccache_dir }}" + dest: "{{ remote_ccache_dir }}" + mode: preserve + remote_src: no + delegate_to: localhost + when: arch == "s390x" + - name: Run the builder image community.general.make: chdir: "{{ ansible_env.GITHUB_WORKSPACE | default(collector_root) }}" @@ -43,6 +54,13 @@ # ensure this action is printed tags: [print_action] + - name: Copy ccache back to local machine + ansible.builtin.fetch: + src: "{{ remote_ccache_dir }}" + dest: "{{ local_ccache_dir }}" + flat: yes + when: arch == "s390x" + - name: Retag collector image to arch specific community.docker.docker_image: name: "{{ collector_image }}"