Skip to content

Commit 8e520e6

Browse files
authored
feat: validate catalog (#272)
* feat: validate catalog * fix * avoid checkout and create empty file for testing purposes * fix * test failures * fix
1 parent 6ee9232 commit 8e520e6

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

.github/workflows/no-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- '!buildkite/run/**'
1414
- '!check-dependent-jobs/**'
1515
- '!elastic/github-commands/**'
16+
- '!elastic/validate-catalog/**'
1617
- '!git/setup/**'
1718
- '!github/backport-active/**'
1819
- '!github/project-add/**'
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: test-elastic-validate-catalog
2+
3+
on:
4+
merge_group: ~
5+
workflow_dispatch: ~
6+
pull_request:
7+
paths:
8+
- 'elastic/validate-catalog/**'
9+
- '.github/workflows/test-elastic-validate-catalog.yml'
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- 'elastic/validate-catalog/**'
15+
- '.github/workflows/test-elastic-validate-catalog.yml'
16+
17+
permissions:
18+
contents: read
19+
packages: read
20+
21+
jobs:
22+
test:
23+
needs:
24+
- main
25+
- failed
26+
runs-on: ubuntu-latest
27+
steps:
28+
- id: check
29+
uses: elastic/oblt-actions/check-dependent-jobs@v1
30+
with:
31+
jobs: ${{ toJSON(needs) }}
32+
- run: ${{ steps.check.outputs.is-success }}
33+
34+
main:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- run: touch catalog-info.yaml
39+
- uses: ./elastic/validate-catalog
40+
41+
failed:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
- run: echo "wrong-content" > catalog-info.yaml
46+
- uses: ./elastic/validate-catalog
47+
id: validate-catalog
48+
continue-on-error: true
49+
- name: Assert is failure
50+
run: test "${{steps.validate-catalog.outcome}}" = "failure"

elastic/validate-catalog/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# <!--name-->elastic/validate-catalog<!--/name-->
2+
3+
[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https://github.com/search?q=elastic%2Foblt-actions%2Felastic%2Fvalidate-catalog+%28path%3A.github%2Fworkflows+OR+path%3A**%2Faction.yml+OR+path%3A**%2Faction.yaml%29&type=code)
4+
[![test-elastic-validate-catalog](https://github.com/elastic/oblt-actions/actions/workflows/test-elastic-validate-catalog.yml/badge.svg?branch=main)](https://github.com/elastic/oblt-actions/actions/workflows/test-elastic-validate-catalog.yml)
5+
6+
<!--description-->
7+
Run the catalog-info validation
8+
<!--/description-->
9+
10+
## Inputs
11+
<!--inputs-->
12+
| Name | Description | Required | Default |
13+
|-------------------|-----------------------------------|----------|-----------------------------------------------------------------------|
14+
| `container-image` | The catalog info container image. | `false` | `ghcr.io/elastic/observability-robots/ci-agent-images/pipelib:latest` |
15+
| `github-token` | The GitHub access token. | `false` | `${{ github.token }}` |
16+
<!--/inputs-->
17+
18+
## Outputs
19+
20+
<!--outputs-->
21+
| Name | Description |
22+
|------|-------------|
23+
<!--/outputs-->
24+
25+
## Usage
26+
27+
You need to grant the read access to the container image called [pipelib](https://github.com/orgs/elastic/packages?tab=packages&q=pipelib). It's not public available but granted to individual GitHub repositories.
28+
29+
30+
<!--usage action="elastic/oblt-actions/**" version="env:VERSION"-->
31+
```yaml
32+
---
33+
name: catalog-info
34+
35+
on:
36+
push:
37+
branches:
38+
- main
39+
pull_request:
40+
branches:
41+
- main
42+
paths:
43+
- 'catalog-info.yaml'
44+
45+
permissions:
46+
contents: read
47+
48+
jobs:
49+
validate:
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
packages: read
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: elastic/oblt-actions/elastic/validate-catalog@v1
57+
```
58+
<!--/usage-->

elastic/validate-catalog/action.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: elastic/validate-catalog
3+
description: |
4+
Run the catalog-info validation
5+
6+
inputs:
7+
container-image:
8+
description: 'The catalog info container image.'
9+
required: false
10+
type: string
11+
default: 'ghcr.io/elastic/observability-robots/ci-agent-images/pipelib:latest'
12+
github-token:
13+
description: 'The GitHub access token.'
14+
required: false
15+
type: string
16+
default: ${{ github.token }}
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ inputs.github-token }}
26+
27+
- run: docker pull --quiet ${{ env.IMAGE }}
28+
shell: bash
29+
env:
30+
IMAGE: ${{ inputs.container-image }}
31+
32+
- run: |-
33+
docker run -t \
34+
--mount type=bind,source=./catalog-info.yaml,target=/home/app/catalog-info.yaml \
35+
${{ env.IMAGE }} \
36+
rre validate --backstage-entity-aware --verbose catalog-info.yaml
37+
shell: bash
38+
env:
39+
IMAGE: ${{ inputs.container-image }}

0 commit comments

Comments
 (0)