diff --git a/.ci/updatecli/update-compose.yml b/.ci/updatecli/update-compose.yml new file mode 100644 index 000000000..ed5476a4c --- /dev/null +++ b/.ci/updatecli/update-compose.yml @@ -0,0 +1,6 @@ +policies: + - name: Handle apm-data server specs + policy: docker pull ghcr.io/elastic/oblt-updatecli-policies/apm/apm-data-spec:0.0.1@sha256:1b8a9876bb8ff9d4b61a0b655b957f10e9c65de0c8a333a88b7424d10b498adc + values: + - .ci/updatecli/values.d/scm.yaml + - .ci/updatecli/values.d/apm-data-spec.yaml diff --git a/.ci/updatecli/updatecli.d/update-gherkin-specs.yml b/.ci/updatecli/updatecli.d/update-gherkin-specs.yml index 13f0617a9..0296437b9 100644 --- a/.ci/updatecli/updatecli.d/update-gherkin-specs.yml +++ b/.ci/updatecli/updatecli.d/update-gherkin-specs.yml @@ -6,27 +6,27 @@ scms: kind: github spec: user: '{{ requiredEnv "GITHUB_ACTOR" }}' - owner: "{{ .github.owner }}" - repository: "{{ .github.repository }}" + owner: "{{ .scm.owner }}" + repository: "{{ .scm.repository }}" token: '{{ requiredEnv "GITHUB_TOKEN" }}' username: '{{ requiredEnv "GITHUB_ACTOR" }}' - branch: "{{ .github.branch }}" + branch: "{{ .scm.branch }}" commitusingapi: true apm: kind: github spec: user: '{{ requiredEnv "GITHUB_ACTOR" }}' - owner: "{{ .github.owner }}" - repository: "{{ .github.apm_repository }}" + owner: "{{ .scm.owner }}" + repository: "{{ .scm.apm_repository }}" token: '{{ requiredEnv "GITHUB_TOKEN" }}' username: '{{ requiredEnv "GITHUB_ACTOR" }}' - branch: "{{ .github.branch }}" + branch: "{{ .scm.branch }}" sources: sha: kind: file spec: - file: 'https://github.com/{{ .github.owner }}/{{ .github.apm_repository }}/commit/{{ .github.branch }}.patch' + file: 'https://github.com/{{ .scm.owner }}/{{ .scm.apm_repository }}/commit/{{ .scm.branch }}.patch' matchpattern: "^From\\s([0-9a-f]{40})\\s" transformers: - findsubmatch: @@ -36,7 +36,7 @@ sources: dependson: - sha spec: - command: gh api /repos/{{ .github.owner }}/{{ .github.apm_repository }}/commits/{{ source "sha" }}/pulls --jq '.[].html_url' + command: gh api /repos/{{ .scm.owner }}/{{ .scm.apm_repository }}/commits/{{ source "sha" }}/pulls --jq '.[].html_url' environments: - name: GITHUB_TOKEN - name: PATH diff --git a/.ci/updatecli/updatecli.d/update-json-specs.yml b/.ci/updatecli/updatecli.d/update-json-specs.yml index ae9816775..a92587e4a 100644 --- a/.ci/updatecli/updatecli.d/update-json-specs.yml +++ b/.ci/updatecli/updatecli.d/update-json-specs.yml @@ -6,27 +6,27 @@ scms: kind: github spec: user: '{{ requiredEnv "GITHUB_ACTOR" }}' - owner: "{{ .github.owner }}" - repository: "{{ .github.repository }}" + owner: "{{ .scm.owner }}" + repository: "{{ .scm.repository }}" token: '{{ requiredEnv "GITHUB_TOKEN" }}' username: '{{ requiredEnv "GITHUB_ACTOR" }}' - branch: "{{ .github.branch }}" + branch: "{{ .scm.branch }}" commitusingapi: true apm: kind: github spec: user: '{{ requiredEnv "GITHUB_ACTOR" }}' - owner: "{{ .github.owner }}" - repository: "{{ .github.apm_repository }}" + owner: "{{ .scm.owner }}" + repository: "{{ .scm.apm_repository }}" token: '{{ requiredEnv "GITHUB_TOKEN" }}' username: '{{ requiredEnv "GITHUB_ACTOR" }}' - branch: "{{ .github.branch }}" + branch: "{{ .scm.branch }}" sources: sha: kind: file spec: - file: 'https://github.com/{{ .github.owner }}/{{ .github.apm_repository }}/commit/{{ .github.branch }}.patch' + file: 'https://github.com/{{ .scm.owner }}/{{ .scm.apm_repository }}/commit/{{ .scm.branch }}.patch' matchpattern: "^From\\s([0-9a-f]{40})\\s" transformers: - findsubmatch: @@ -36,7 +36,7 @@ sources: dependson: - sha spec: - command: gh api /repos/{{ .github.owner }}/{{ .github.apm_repository }}/commits/{{ source "sha" }}/pulls --jq '.[].html_url' + command: gh api /repos/{{ .scm.owner }}/{{ .scm.apm_repository }}/commits/{{ source "sha" }}/pulls --jq '.[].html_url' environments: - name: GITHUB_TOKEN - name: PATH @@ -67,7 +67,7 @@ actions: ### Why *Changeset* * {{ source "pull_request" }} - * https://github.com/{{ .github.owner }}/{{ .github.apm_repository }}/commit/{{ source "sha" }} + * https://github.com/{{ .scm.owner }}/{{ .scm.apm_repository }}/commit/{{ source "sha" }} title: '[Automation] Update JSON specs' targets: diff --git a/.ci/updatecli/updatecli.d/update-specs.yml b/.ci/updatecli/updatecli.d/update-specs.yml deleted file mode 100644 index e9bbaf945..000000000 --- a/.ci/updatecli/updatecli.d/update-specs.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: update-specs -pipelineid: update-schema-specs - -scms: - default: - kind: github - spec: - user: '{{ requiredEnv "GITHUB_ACTOR" }}' - owner: "{{ .github.owner }}" - repository: "{{ .github.repository }}" - token: '{{ requiredEnv "GITHUB_TOKEN" }}' - username: '{{ requiredEnv "GITHUB_ACTOR" }}' - branch: "{{ .github.branch }}" - commitusingapi: true - - apm-data: - kind: github - spec: - user: '{{ requiredEnv "GITHUB_ACTOR" }}' - owner: "{{ .github.owner }}" - repository: "{{ .github.apm_data_repository }}" - token: '{{ requiredEnv "GITHUB_TOKEN" }}' - username: '{{ requiredEnv "GITHUB_ACTOR" }}' - branch: "{{ .github.branch }}" - -sources: - sha: - kind: file - spec: - file: 'https://github.com/{{ .github.owner }}/{{ .github.apm_data_repository }}/commit/{{ .github.branch }}.patch' - matchpattern: "^From\\s([0-9a-f]{40})\\s" - transformers: - - findsubmatch: - pattern: "[0-9a-f]{40}" - pull_request: - kind: shell - dependson: - - sha - spec: - command: gh api /repos/{{ .github.owner }}/{{ .github.apm_data_repository }}/commits/{{ source "sha" }}/pulls --jq '.[].html_url' - environments: - - name: GITHUB_TOKEN - - name: PATH - agent-specs-tarball: - kind: shell - scmid: apm-data - dependson: - - sha - spec: - command: tar cvzf {{ requiredEnv "GITHUB_WORKSPACE" }}/json-schema.tgz . - environments: - - name: PATH - workdir: "{{ .specs.apm_data_path }}" - -actions: - pr: - kind: "github/pullrequest" - scmid: default - sourceid: sha - spec: - automerge: false - draft: false - labels: - - "automation" - description: |- - ### What - APM agent json server schema automatic sync - - ### Why - *Changeset* - * {{ source "pull_request" }} - * https://github.com/{{ .github.owner }}/{{ .github.apm_data_repository }}/commit/{{ source "sha" }} - title: '[Automation] Update JSON server schema specs' - -targets: - agent-json-schema: - name: APM agent json server schema {{ source "sha" }} - scmid: default - disablesourceinput: true - kind: shell - spec: - # git diff helps to print what it changed, If it is empty, then updatecli report a success with no changes applied. - # See https://www.updatecli.io/docs/plugins/resource/shell/#_shell_target - command: 'tar -xzf {{ requiredEnv "GITHUB_WORKSPACE" }}/json-schema.tgz && git --no-pager diff' - workdir: "{{ .apm_agent.server_schema_specs_path }}" diff --git a/.ci/updatecli/values.d/apm-data-spec.yml b/.ci/updatecli/values.d/apm-data-spec.yml new file mode 100644 index 000000000..282d7f78e --- /dev/null +++ b/.ci/updatecli/values.d/apm-data-spec.yml @@ -0,0 +1,2 @@ +apm_schema_specs_path: tests/APM_Server_intake_API_schema/latest_used +signedcommit: true \ No newline at end of file diff --git a/.ci/updatecli/values.d/scm.yml b/.ci/updatecli/values.d/scm.yml new file mode 100644 index 000000000..b51fb2b1b --- /dev/null +++ b/.ci/updatecli/values.d/scm.yml @@ -0,0 +1,6 @@ +scm: + enabled: true + owner: elastic + repository: apm-agent-php + apm_repository: apm + branch: main \ No newline at end of file diff --git a/.ci/updatecli/values.d/specs.yml b/.ci/updatecli/values.d/specs.yml new file mode 100644 index 000000000..9e4f85482 --- /dev/null +++ b/.ci/updatecli/values.d/specs.yml @@ -0,0 +1,6 @@ +specs: + apm_json_path: "tests/agents/json-specs" + apm_gherkin_path: "tests/agents/gherkin-specs" +apm_agent: + gherkin_specs_path: "tests/APM_Agents_shared/gherkin-specs" + json_specs_path: "tests/APM_Agents_shared/json-specs" \ No newline at end of file diff --git a/.ci/updatecli/values.yml b/.ci/updatecli/values.yml deleted file mode 100644 index e4e37b1a0..000000000 --- a/.ci/updatecli/values.yml +++ /dev/null @@ -1,14 +0,0 @@ -github: - owner: "elastic" - repository: "apm-agent-php" - apm_repository: "apm" - apm_data_repository: "apm-data" - branch: "main" -specs: - apm_data_path: "input/elasticapm/docs/spec/v2" - apm_json_path: "tests/agents/json-specs" - apm_gherkin_path: "tests/agents/gherkin-specs" -apm_agent: - gherkin_specs_path: "tests/APM_Agents_shared/gherkin-specs" - json_specs_path: "tests/APM_Agents_shared/json-specs" - server_schema_specs_path: "tests/APM_Server_intake_API_schema/latest_used" \ No newline at end of file diff --git a/.github/workflows/updatecli.yml b/.github/workflows/updatecli.yml index a9e2f509b..e6762c006 100644 --- a/.github/workflows/updatecli.yml +++ b/.github/workflows/updatecli.yml @@ -16,7 +16,37 @@ jobs: - uses: elastic/oblt-actions/updatecli/run@v1 with: - command: "--experimental apply --config .ci/updatecli/updatecli.d --values .ci/updatecli/values.yml" + command: "--experimental apply --config .ci/updatecli/updatecli.d --values .ci/updatecli/values.d/scm.yml" + env: + GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }} + + - if: failure() + uses: elastic/oblt-actions/slack/send@v1 + with: + bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + channel-id: "#apm-agent-php" + message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on " + + compose: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: elastic/oblt-actions/updatecli/run@v1 + with: + command: --experimental compose diff --file .ci/updatecli/update-compose.yml + env: + GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }} + + - uses: elastic/oblt-actions/updatecli/run@v1 + with: + command: --experimental compose apply --file .ci/updatecli/update-compose.yml env: GITHUB_TOKEN: ${{ secrets.UPDATECLI_GH_TOKEN }}