-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dashboard-as-Code actions & workflow #10
Merged
Merged
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
de1a91e
Add new action to build dashboards as code
8dafcad
Rename workflow file
eef95a5
add new action validate resources (1rst simple version)
4805acf
Avoid doing checks already done by the CLI
abbd6c2
remove useless quotes
dbe9801
build dac + validate: add missing flags
6db5e62
add new action to preview dashboards
24a514f
Fix wrong names
b8822c9
add new action to diff dashboards
6f60ab3
update some descriptions
63f4715
add new actions to apply resources
37f2120
update file & dir inputs descs
089b4d8
1rst working version for the merge main / deploy case
b303ca3
fix skip-tls flag usage
ff5c136
Factorize login logic
58b87cc
Move login to a dedicated action
6e9c322
Add conditions to change behavior between PR vs main branch
2b6dc4c
Add login step in individual tests that require it
aad1ef3
Post preview comment (+ remove configurable output format)
146bd3d
preview: replace configurable prefix by PR number
b5a4888
Preview: bring back configurable prefix in action + pass github PR nu…
7a2015b
Fix diff
155cb25
diff: upload diff files as artifacts
20f9152
update gitignore
e47bee3
bump github-script version used
d039a3a
Update diff message
739bd9a
Fix online validation
22270bf
dont skip diff in DaC test
c5380db
fix diff stage
b0edc84
Deploy if default branch
c70b6ae
consistent naming convention for inputs
939f22c
Improve diff output
17c8685
change creds to secrets
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
name: Reusable Workflow for Dashboard-as-Code CI/CD | ||
on: | ||
workflow_call: | ||
inputs: | ||
# general: | ||
url: | ||
description: The URL of the Perses API server where to deploy the dashboard preview. | ||
type: string | ||
required: true | ||
directory: | ||
description: Path to the directory containing the dashboards as code (mutually exclusive with `file`). | ||
type: string | ||
required: false | ||
file: | ||
description: Path to the file that contains the dashboards as code (mutually exclusive with `directory`). | ||
type: string | ||
required: false | ||
project: | ||
description: If present, the project scope for this CLI request. | ||
type: string | ||
required: false | ||
# skip: | ||
skip_preview: | ||
description: Skip the dashboard preview stage if provided. | ||
type: boolean | ||
required: false | ||
skip_diff: | ||
description: Skip the dashboard diff generation stage if provided. | ||
type: boolean | ||
required: false | ||
skip_deploy: | ||
description: Skip the dashboard deployment stage if provided. | ||
type: boolean | ||
required: false | ||
# auth: | ||
username: | ||
description: Username for basic authentication to the API server. | ||
type: string | ||
required: false | ||
password: | ||
description: Password for basic authentication to the API server. | ||
type: string | ||
required: false | ||
token: | ||
description: Bearer token for authentication to the API server. | ||
type: string | ||
required: false | ||
provider: | ||
description: External authentication provider identifier. (slug_id) | ||
type: string | ||
required: false | ||
client-id: | ||
description: Client ID used for robotic access when using external authentication provider. | ||
type: string | ||
required: false | ||
client-secret: | ||
description: Client Secret used for robotic access when using external authentication provider. | ||
type: string | ||
required: false | ||
insecure-skip-tls-verify: | ||
description: If true the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. | ||
type: string | ||
required: false | ||
# validate-specific: | ||
server-validation: | ||
description: When enabled, requests the API to make additional validation. | ||
type: boolean | ||
required: false | ||
# preview-specific: | ||
ttl: | ||
description: Time To Live of the dashboard preview (default "1d"). | ||
type: string | ||
required: false | ||
# deploy-specific: | ||
force: | ||
description: If present, dashboards will be deployed even if the projects are not consistent between the --project flag and the dashboards metadata (the latter has priority). | ||
type: boolean | ||
required: false | ||
|
||
jobs: | ||
dac: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install necessary tools | ||
uses: ./actions/setup_environment | ||
with: | ||
enable_go: true | ||
enable_cue: true | ||
|
||
- name: Install percli | ||
uses: ./actions/install_percli | ||
with: | ||
cli_version: "latest" | ||
|
||
- name: Build the dashboards | ||
uses: ./actions/build_dac | ||
with: | ||
directory: ${{ inputs.directory }} | ||
file: ${{ inputs.file }} | ||
|
||
- name: Login to the API server | ||
uses: ./actions/login | ||
with: | ||
url: ${{ inputs.url }} | ||
username: ${{ inputs.username }} | ||
password: ${{ inputs.password }} | ||
token: ${{ inputs.token }} | ||
provider: ${{ inputs.provider }} | ||
client-id: ${{ inputs.client-id }} | ||
client-secret: ${{ inputs.client-secret }} | ||
insecure-skip-tls-verify: ${{ inputs.insecure-skip-tls-verify }} | ||
|
||
- name: Validate the dashboards | ||
uses: ./actions/validate_resources | ||
with: | ||
directory: ./built | ||
online: ${{ inputs.server-validation }} | ||
|
||
- name: Preview the dashboards | ||
if: ${{ github.event_name == 'pull_request' && !inputs.skip_preview }} | ||
uses: ./actions/preview_dashboards | ||
with: | ||
directory: ./built | ||
project: ${{ inputs.project }} | ||
prefix: ${{ github.event.pull_request.number }} | ||
ttl: ${{ inputs.ttl }} | ||
|
||
- name: Generate dashboards diffs | ||
if: ${{ github.event_name == 'pull_request' && !inputs.skip_diff }} | ||
uses: ./actions/diff_dashboards | ||
with: | ||
directory: ./built | ||
project: ${{ inputs.project }} | ||
|
||
- name: Deploy the dashboards | ||
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && !inputs.skip_deploy }} | ||
uses: ./actions/apply_resources | ||
with: | ||
directory: ./built | ||
project: ${{ inputs.project }} | ||
force: ${{ inputs.force }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Test Apply Resources | ||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
- snapshot/* | ||
tags: | ||
- v* | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
test-apply-resources: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install percli | ||
uses: ./actions/install_percli | ||
with: | ||
cli_version: "latest" | ||
|
||
- name: Login to the API server | ||
uses: ./actions/login | ||
with: | ||
url: https://demo.perses.dev | ||
username: test | ||
password: test | ||
|
||
- name: Test apply resources | ||
uses: ./actions/apply_resources | ||
with: | ||
file: ./testdata/resources_folder/dashboard.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Test Build Dashboards-as-Code | ||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
- snapshot/* | ||
tags: | ||
- v* | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
test-build-dac: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install percli | ||
uses: ./actions/install_percli | ||
with: | ||
cli_version: latest | ||
|
||
- name: Install cue binary | ||
uses: ./actions/setup_environment | ||
with: | ||
enable_go: true | ||
enable_cue: true | ||
|
||
- name: Test build DaC with directory | ||
uses: ./actions/build_dac | ||
with: | ||
directory: ./testdata/dac_folder | ||
|
||
- name: Test build DaC with file | ||
uses: ./actions/build_dac | ||
with: | ||
file: ./testdata/dac_file.cue | ||
|
||
- name: Test build DaC with both inputs (should fail) | ||
id: test_fail | ||
uses: ./actions/build_dac | ||
with: | ||
directory: ./testdata/dac_folder | ||
file: ./testdata/dac_file.cue | ||
continue-on-error: true | ||
|
||
- name: Validate failure for both inputs | ||
run: | | ||
if [ "${{ steps.test_fail.outcome }}" != "failure" ]; then | ||
echo "Error: Action did not fail as expected when both inputs were provided." | ||
exit 1 | ||
else | ||
echo "Success: Action failed as expected." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Test the Dashboard-as-Code workflow | ||
|
||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
- snapshot/* | ||
tags: | ||
- v* | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
test-dac: | ||
uses: ./.github/workflows/dac.yaml | ||
with: | ||
url: https://demo.perses.dev | ||
directory: ./testdata/dac_folder | ||
server-validation: true | ||
username: test | ||
password: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Test Diff Dashboards | ||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
- snapshot/* | ||
tags: | ||
- v* | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
test-diff-dashboards: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install percli | ||
uses: ./actions/install_percli | ||
with: | ||
cli_version: "latest" | ||
|
||
- name: Login to the API server | ||
uses: ./actions/login | ||
with: | ||
url: https://demo.perses.dev | ||
username: test | ||
password: test | ||
|
||
- name: Test dashboard diff | ||
uses: ./actions/diff_dashboards | ||
with: | ||
directory: ./testdata/resources_folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Test Preview Dashboards | ||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
- snapshot/* | ||
tags: | ||
- v* | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
test-preview-dashboards: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install percli | ||
uses: ./actions/install_percli | ||
with: | ||
cli_version: "latest" | ||
|
||
- name: Login to the API server | ||
uses: ./actions/login | ||
with: | ||
url: https://demo.perses.dev | ||
username: test | ||
password: test | ||
|
||
- name: Test dashboard preview | ||
uses: ./actions/preview_dashboards | ||
with: | ||
file: ./testdata/resources_folder/dashboard.json | ||
prefix: test-preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Test resources validation | ||
on: | ||
workflow_dispatch: # Allow manual triggering | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
- snapshot/* | ||
tags: | ||
- v* | ||
pull_request: | ||
merge_group: | ||
jobs: | ||
test-validate-resources: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install percli | ||
uses: ./actions/install_percli | ||
with: | ||
cli_version: latest | ||
|
||
- name: Install cue binary | ||
uses: ./actions/setup_environment | ||
with: | ||
enable_go: true | ||
enable_cue: true | ||
|
||
- name: Test resources validation | ||
uses: ./actions/validate_resources | ||
with: | ||
directory: ./testdata/resources_folder | ||
|
||
- name: Test resources validation with file | ||
uses: ./actions/validate_resources | ||
with: | ||
file: ./testdata/resource.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,7 @@ | |
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
Thumbs.db | ||
|
||
# DaC-generated | ||
built |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some keys are using "_" others "-", should we align everything? (ie: skip_deploy)