Skip to content

Add tools Ci cache #1418

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

Merged
merged 13 commits into from
Mar 4, 2025
Merged
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
65 changes: 55 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Build

permissions:
contents: read

on:
push:
branches:
Expand All @@ -9,32 +12,74 @@ on:
pull_request:

jobs:
lint-fmt:
name: Lint and Format
setup:
name: Setup tools
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.tools-cache.outputs.cache-hit }}
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Tools cache
id: tools-cache
uses: actions/cache@v4
with:
path: |
~/go/bin
/usr/local/bin/promtool
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
- name: Install CI dependencies
if: steps.tools-cache.outputs.cache-hit != 'true'
run: make install-ci-deps

lint-fmt:
name: Lint and Format
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Restore Tools cache
uses: actions/cache@v4
with:
path: |
~/go/bin
/usr/local/bin/promtool
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
- name: Lint and Format
run: make lint-fmt

tests:
name: Run Tests
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Install CI dependencies
run: make install-ci-deps
- name: Restore Tools cache
uses: actions/cache@v4
with:
path: |
~/go/bin
/usr/local/bin/promtool
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
- name: Run Tests
run: make tests
51 changes: 33 additions & 18 deletions .github/workflows/test-mixins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,43 @@ on:
- master

jobs:
check-for-changed-mixins:
name: Check for changes
setup:
name: Setup tools
runs-on: ubuntu-latest
outputs:
changed-mixins: ${{ steps.changed-mixins.outputs.all_changed_files }}
cache-hit: ${{ steps.tools-cache.outputs.cache-hit }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23

- name: Tools cache
id: tools-cache
uses: actions/cache@v4
with:
path: |
~/go/bin
/usr/local/bin/promtool
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
- name: Install CI dependencies
if: steps.tools-cache.outputs.cache-hit != 'true'
run: make install-ci-deps


check-for-changed-mixins:
name: Check for changes
needs: setup
runs-on: ubuntu-latest
outputs:
changed-mixins: ${{ steps.changed-mixins.outputs.all_changed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed mixins
id: changed-mixins
uses: tj-actions/changed-files@v44
Expand All @@ -41,7 +59,6 @@ jobs:
**-mixin/
**-observ-lib/
matrix: true

- name: List all changed mixins
run: echo '${{ steps.changed-mixins.outputs.all_changed_files }}'

Expand All @@ -54,7 +71,7 @@ jobs:
pull-requests: write
repository-projects: write
timeout-minutes: 15
needs: [check-for-changed-mixins]
needs: [setup, check-for-changed-mixins]
strategy:
matrix:
mixin: ${{ fromJSON(needs.check-for-changed-mixins.outputs.changed-mixins) }}
Expand All @@ -73,27 +90,26 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23

- name: Install CI dependencies
run: make install-ci-deps

- name: Restore Tools cache
uses: actions/cache@v4
with:
path: |
~/go/bin
/usr/local/bin/promtool
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
- name: Install mixin dependencies
working-directory: ./${{ matrix.mixin }}
run: make build

- name: Lint mixin
working-directory: ./${{ matrix.mixin }}
run: make lint

- name: Check for unexpected changes in generated files
working-directory: ./${{ matrix.mixin }}
run: "make dashboards_out prometheus_alerts.yaml prometheus_rules.yaml && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"

run: "make -B dashboards_out prometheus_alerts.yaml prometheus_rules.yaml && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"
- name: Wait for Grafana and validate dashboards
working-directory: ./${{ matrix.mixin }}
env:
Expand All @@ -104,7 +120,6 @@ jobs:

# Try to deploy dashboards
make deploy_dashboards

- name: Run promtool test for rules
working-directory: ./${{ matrix.mixin }}
run: make test
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ else
ARCH := $(UNAME_M)
endif

# Check if .github/workflows/*.yml need to be updated
# when changing the install-ci-deps target.
install-ci-deps: install-promtool
go install github.com/google/go-jsonnet/cmd/jsonnet@v0.20.0
go install github.com/google/go-jsonnet/cmd/jsonnetfmt@v0.20.0
Expand Down
4 changes: 2 additions & 2 deletions Makefile_mixin
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ dashboards_out: mixin.libsonnet $(wildcard **/*.libsonnet) $(wildcard **/*.jsonn
@mkdir -p dashboards_out
mixtool generate dashboards mixin.libsonnet -d dashboards_out

prometheus_alerts.yaml: $(wildcard vendor/**/alerts.yaml) $(wildcard vendor/**/alerts.libsonnet) mixin.libsonnet $(wildcard alerts.libsonnet) $(wildcard signals/*) $(wildcard alerts/*)
prometheus_alerts.yaml: mixin.libsonnet $(wildcard vendor/**/alerts.yaml) $(wildcard alerts/*) $(wildcard vendor/**/alerts.libsonnet) $(wildcard alerts.libsonnet) $(wildcard signals/*)
@mkdir -p prometheus_rules_out
@if [ -f alerts.libsonnet -o -d alerts ]; then \
mixtool generate alerts mixin.libsonnet -a prometheus_rules_out/prometheus_alerts.yaml; \
else \
touch prometheus_rules_out/prometheus_alerts.yaml; \
fi
prometheus_rules.yaml: $(wildcard vendor/**/rules.yaml) $(wildcard vendor/**/rules.libsonnet) mixin.libsonnet $(wildcard rules.libsonnet) $(wildcard signals/*) $(wildcard rules/*)
prometheus_rules.yaml: mixin.libsonnet $(wildcard vendor/**/rules.yaml) $(wildcard rules/*) $(wildcard vendor/**/rules.libsonnet) $(wildcard rules.libsonnet) $(wildcard signals/*)
@if [ -f rules.libsonnet -o -d rules ]; then \
mixtool generate rules mixin.libsonnet -a prometheus_rules_out/prometheus_rules.yaml; \
else \
Expand Down
18 changes: 9 additions & 9 deletions process-observ-lib/dashboards_out/process-dashboard.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion process-observ-lib/mixin.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ local proc =
proclib.new()
+ proclib.withConfigMixin(
{
filteringSelector: 'job!=""',
metricsSource: 'java_otel',
}
);
Expand Down
Loading