Skip to content

.github/workflows/push.yml: enable ccache #10395

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
- '**'
permissions:
contents: read
env:
CC: ccache gcc
CXX: ccache g++
jobs:
LINUX_X64:
strategy:
Expand All @@ -41,6 +44,13 @@ jobs:
uses: ./.github/actions/setup-oracle
- name: apt
uses: ./.github/actions/apt-x64
- name: ccache
uses: hendrikmuhs/[email protected]
with:
# This duplicates the "job.name" expression above because
# GitHub has no way to query the job name (github.job is the
# job id, not the job name)
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}-${{hashFiles('main/php_version.h')}}"
Comment on lines +50 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# This duplicates the "job.name" expression above because
# GitHub has no way to query the job name (github.job is the
# job id, not the job name)
key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}-${{hashFiles('main/php_version.h')}}"
key: "${{ github.workflow }}-${{ github.job }}-${{ toJSON(matrix) }}-${{ hashFiles('main/php_version.h') }}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better because it doesn't duplicate the expression, but it's worse because a hash is more obscure. I don't have a real opinion on what to choose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no hash added and json is quite readable :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's JSON, not hash of a JSON ... yes, that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't work:

  Error: Restoring cache failed: ValidationError: Key Validation Error: ccache-Push-LINUX_X64-{
    "debug": true,
    "zts": false
  }-10c280ee69e81a8f532bab2756a061cccc70829ec83708c23eb95d1f14f49c53- cannot contain commas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash of JSON would solve that, but no hash function exists :( :) What about moving the ccache step into separate file and calculating the cache key there using bash?

see https://github.com/atk4/core/blob/develop/.github/workflows/test-unit.yml l37 and l42 for how data can be passed between steps, ie. from bash step to GH action step

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's worth the complexity.

- name: ./configure
uses: ./.github/actions/configure-x64
with:
Expand Down Expand Up @@ -89,6 +99,10 @@ jobs:
uses: actions/checkout@v3
- name: apt
uses: ./.github/actions/apt-x32
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
- name: ./configure
uses: ./.github/actions/configure-x32
with:
Expand All @@ -115,6 +129,10 @@ jobs:
uses: actions/checkout@v3
- name: brew
uses: ./.github/actions/brew
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
- name: ./configure
uses: ./.github/actions/configure-macos
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ tmp-php.ini
# ------------------------------------------------------------------------------
/branch-commit-cache.json
/junit.out.xml
/.ccache/

# ------------------------------------------------------------------------------
# Special cases to invert previous ignore patterns
Expand Down