Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cb1d810
feat(ci): Go caching improvements
xnyo Dec 18, 2025
a92c0dc
add missing new line
xnyo Dec 18, 2025
132c2f3
revert go tooling cache
xnyo Dec 18, 2025
3f0f300
revert go sum caching
xnyo Dec 18, 2025
08e986b
Revert "revert go sum caching"
xnyo Dec 18, 2025
2803046
Revert "revert go tooling cache"
xnyo Dec 18, 2025
2d50ae9
test(act): better cache warmup, removed rsync from package step
xnyo Dec 18, 2025
989d73f
cache trufflehog binary
xnyo Dec 18, 2025
a25674c
Merge branch 'giuseppe/caching-split-3' into giuseppe/caching-split-4
xnyo Dec 18, 2025
749ca79
Update .github/workflows/ci.yml
xnyo Dec 18, 2025
94c5ce0
Update .github/workflows/ci.yml
xnyo Dec 18, 2025
ada466e
Update .github/workflows/ci.yml
xnyo Dec 18, 2025
cd31772
Update actions/internal/plugins/setup/action.yml
xnyo Dec 18, 2025
d067c4c
Merge branch 'giuseppe/caching-split-1' into giuseppe/caching-split-2
xnyo Dec 18, 2025
87bef1f
Merge branch 'giuseppe/caching-split-2' into giuseppe/caching-split-3
xnyo Dec 18, 2025
8880b8a
Update actions/internal/plugins/setup/action.yml
xnyo Dec 18, 2025
3b41a55
Update actions/internal/plugins/trufflehog/action.yml
xnyo Dec 18, 2025
79f293d
pin mage
xnyo Dec 18, 2025
e728280
pass mage-version from ci workflow
xnyo Dec 18, 2025
271416f
Merge branch 'giuseppe/caching-split-3' into giuseppe/caching-split-4
xnyo Dec 18, 2025
436dda9
read mage version from ci.yml and pass it to act cache warmup workflow
xnyo Dec 18, 2025
63b1dfd
update trufflehog action input descriptions
xnyo Dec 18, 2025
a0bfe9c
Merge branch 'giuseppe/caching-split-3' into giuseppe/caching-split-4
xnyo Dec 18, 2025
bc1cba0
add mage-version input to ci.yml
xnyo Dec 18, 2025
bfa3367
pass mage-version from cd.yml
xnyo Dec 18, 2025
83f2d3a
take go version for cache key from setup-go step output
xnyo Dec 18, 2025
67413aa
Update actions/internal/plugins/package/package.sh
xnyo Dec 18, 2025
8accee0
Merge branch 'giuseppe/caching-split-3' into giuseppe/caching-split-4
xnyo Dec 18, 2025
713234e
Update actions/internal/plugins/setup/action.yml
xnyo Dec 18, 2025
971550b
Merge remote-tracking branch 'origin/giuseppe/caching-split-4' into g…
xnyo Dec 18, 2025
55f98af
Apply suggestions from code review
xnyo Dec 18, 2025
39908e6
Merge branch 'giuseppe/caching-split-3' into giuseppe/caching-split-4
xnyo Dec 18, 2025
f408099
Merge branch 'main' into giuseppe/caching-split-4
xnyo Jan 7, 2026
af82111
Merge branch 'main' into giuseppe/caching-split-4
xnyo Jan 7, 2026
89a9453
Update actions/internal/plugins/package/package.sh
xnyo Jan 7, 2026
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
15 changes: 9 additions & 6 deletions actions/internal/plugins/package/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,18 @@ for file in $(find "$backend_folder" -type f -name "${exe_basename}_*"); do
# Temporary folder for the zip file
tmp=$(mktemp -d)
pushd $tmp > /dev/null

# Copy all files but the executables
mkdir -p "$plugin_id"
rsync -a --exclude "${exe_basename}*" "$dist/" "$plugin_id"
# TODO: this instead of rsync
# find "$dist" -type f ! -name "${exe_basename}*" -exec cp --parents {} "$plugin_id" \;

# Copy all files but the executables, preserving permissions and mod times (similar to rsync)
pushd "$dist" > /dev/null
# -name "${exe_basename}*" -prune: Ignore (prune) all executables
# -o -type f -print0: OR, print file name (NUL-terminated) for use with xargs -0
# Copy with cp, preserving permissions and create any required parent directories to the dest folder
find . -name "${exe_basename}*" -prune -o -type f -print0 | xargs -0 cp -p --parents -t "$tmp/$plugin_id"
popd > /dev/null

# Copy only the current executable
cp "$dist/$file" "$plugin_id/$backend_folder"
cp "$dist/$file" "$tmp/$plugin_id/$backend_folder"
os_arch_zip_fn="$plugin_id-$plugin_version.$os_arch.zip"
echo "Creating package: $os_arch_zip_fn"

Expand Down
32 changes: 26 additions & 6 deletions actions/internal/plugins/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ inputs:
Directory of the plugin, if not in the root of the repository.
required: false
default: .
act-cache-warmup:
description: |
If true, run in a simplified mode for caching Node/Go tooling before running any tests with `act`.
This will not attempt to detect the package manager or cache the plugin's dependencies.
This should only be used when testing with `act`.
required: false
default: "false"
go-version:
description: |
Go version to use.
Expand Down Expand Up @@ -46,13 +53,14 @@ runs:
using: composite
steps:
- name: Detect package manager
if: ${{ inputs.act-cache-warmup != 'true' }}
id: package-manager
uses: grafana/plugin-actions/package-manager-detect@package-manager-detect/v1.0.1
with:
working-directory: ${{ inputs.plugin-directory }}

- name: Install pnpm
if: ${{ steps.package-manager.outputs.name == 'pnpm' }}
if: ${{ inputs.act-cache-warmup != 'true' && steps.package-manager.outputs.name == 'pnpm' }}
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
with:
version: ${{ steps.package-manager.outputs.version }}
Expand All @@ -62,8 +70,8 @@ runs:
with:
node-version: "${{ inputs.node-version }}"
node-version-file: "${{ inputs.node-version-file }}"
cache: ${{ steps.package-manager.outputs.name }}
cache-dependency-path: ${{ steps.package-manager.outputs.lockFilePath }}
cache: ${{ inputs.act-cache-warmup != 'true' && steps.package-manager.outputs.name || '' }}
cache-dependency-path: ${{ inputs.act-cache-warmup != 'true' && steps.package-manager.outputs.lockFilePath || '' }}

# Install additional dependencies that are not built-in to the slim act image
# but are included in the default GitHub Actions runner image and are needed for plugin-ci-workflows.
Expand All @@ -77,8 +85,6 @@ runs:
if ! command -v yarn >/dev/null 2>&1; then
npm install -g yarn
fi
apt-get update
apt-get install -y rsync

- name: Go
id: go
Expand All @@ -87,7 +93,21 @@ runs:
go-version: "${{ inputs.go-version }}"
go-version-file: "${{ inputs.go-version-file }}"
cache: ${{ inputs.go-setup-caching == 'true' }}
cache-dependency-path: ${{ format('{0}/go.sum', inputs.plugin-directory) || '' }}
cache-dependency-path: ${{ inputs.act-cache-warmup != 'true' && format('{0}/go.sum', inputs.plugin-directory) || '' }}

- name: Determine Go bin directory
id: go-bin
shell: bash
run: echo "gobin=$(go env GOPATH)/bin" >> "$GITHUB_OUTPUT"

- name: Cache Go tooling
id: cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: |
${{ steps.go-bin.outputs.gobin }}/golangci-lint
${{ steps.go-bin.outputs.gobin }}/mage
key: go-tools-os=${{ runner.os }}-arch=${{ runner.arch }}-go=${{ steps.go.outputs.go-version }}-mage=${{ inputs.mage-version }}-golangci-lint=${{ inputs.golangci-lint-version }}

- name: Mage
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
Expand Down
30 changes: 17 additions & 13 deletions tests/act/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func TestMain(m *testing.M) {
panic(err)
}

// Read ci.yml to get the default tooling versions, so we can warm up the cache
ciWf, err := workflow.NewBaseWorkflowFromFile(filepath.Join(".github", "workflows", "ci.yml"))
if err != nil {
panic(err)
}

// Warm up act-toolcache volume, otherwise we get weird errors
// when running the "setup/*" actions in parallel tests since they
// all share the same act-toolcache volume.
Expand All @@ -53,28 +59,26 @@ func TestMain(m *testing.M) {
"warmup": {
Name: "Warm up tool cache",
RunsOn: "ubuntu-arm64-small",
// TODO: we should read the go-version and node-version from ci.yml:
// DEFAULT_GO_VERSION and DEFAULT_NODE_VERSION
Steps: []workflow.Step{
{
Name: "Setup Go",
Uses: "actions/setup-go@v6.1.0",
Name: "Warm up tooling",
Uses: "grafana/plugin-ci-workflows/actions/internal/plugins/setup@main",
With: map[string]any{
"go-version": "1.25",
"go-version": ciWf.Env["DEFAULT_GO_VERSION"],
"node-version": ciWf.Env["DEFAULT_NODE_VERSION"],
"golangci-lint-version": ciWf.Env["DEFAULT_GOLANGCI_LINT_VERSION"],
"mage-version": ciWf.Env["DEFAULT_MAGE_VERSION"],
"act-cache-warmup": "true",
},
},
{
Name: "Setup Node.js",
Uses: "actions/setup-node@v4.4.0",
Name: "Warm up Trufflehog",
Uses: "grafana/plugin-ci-workflows/actions/internal/plugins/trufflehog@main",
With: map[string]any{
"node-version": "24",
"trufflehog-version": ciWf.Env["DEFAULT_TRUFFLEHOG_VERSION"],
"setup-only": "true",
},
},
{
Name: "Install yarn",
Run: "npm install -g yarn",
Shell: "bash",
},
},
},
},
Expand Down