From f8dfc049249bc37eab92abd0f10113531e77c471 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 13:50:18 -0300 Subject: [PATCH 01/13] Add GS64 rowan metadata --- .github/workflows/docker-build.yml | 2 +- .github/workflows/integration-tests.yml | 9 ++++---- .github/workflows/loading-groups.yml | 19 +++++++++++------ .github/workflows/loading-gs64-components.yml | 21 +++++++++++++++++++ .github/workflows/markdown-lint.yml | 7 +++++-- .github/workflows/notify.yml | 6 +----- .github/workflows/shellcheck.yml | 9 ++++---- .github/workflows/unit-tests-gs64.yml | 16 ++++++++++++++ .github/workflows/unit-tests.yml | 13 +++++++----- LICENSE | 2 +- README.md | 10 ++++++--- docker/Dockerfile | 18 ++++++---------- rowan/components/Deployment.ston | 20 ++++++++++++++++++ rowan/components/Tests.ston | 21 +++++++++++++++++++ rowan/project.ston | 11 ++++++++++ rowan/projects/Stargate.ston | 11 ++++++++++ rowan/projects/Superluminal.ston | 11 ++++++++++ rowan/specs/Stargate-Consul-CI.ston | 14 +++++++++++++ rowan/specs/Stargate-Consul-Deployment.ston | 9 ++++++++ source/.properties | 3 ++- 20 files changed, 188 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/loading-gs64-components.yml create mode 100644 .github/workflows/unit-tests-gs64.yml create mode 100644 rowan/components/Deployment.ston create mode 100644 rowan/components/Tests.ston create mode 100644 rowan/project.ston create mode 100644 rowan/projects/Stargate.ston create mode 100644 rowan/projects/Superluminal.ston create mode 100644 rowan/specs/Stargate-Consul-CI.ston create mode 100644 rowan/specs/Stargate-Consul-Deployment.ston diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d8fe526..76d923d 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -14,7 +14,7 @@ jobs: name: Build and Publish Docker Images steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 - name: Docker meta diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 2fd90a3..a91a25a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,13 +1,14 @@ name: Integration Tests - -on: [push,pull_request,workflow_dispatch] - +on: + - push + - pull_request + - workflow_dispatch jobs: integration-tests: runs-on: ubuntu-latest name: Integration Tests steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 2 - name: Run tests using Docker diff --git a/.github/workflows/loading-groups.yml b/.github/workflows/loading-groups.yml index 9d58340..35b91e0 100644 --- a/.github/workflows/loading-groups.yml +++ b/.github/workflows/loading-groups.yml @@ -1,18 +1,25 @@ name: Baseline Groups - -on: [push,pull_request,workflow_dispatch] - +on: + - push + - pull_request + - workflow_dispatch jobs: group-loading: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - smalltalk: [ Pharo64-11, Pharo64-10, Pharo64-9.0, Pharo64-8.0 ] - load-spec: [ deployment, examples, tools, development] + smalltalk: + - Pharo64-10 + - Pharo64-11 + load-spec: + - deployment + - examples + - tools + - development name: ${{ matrix.smalltalk }} + ${{ matrix.load-spec }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: hpi-swa/setup-smalltalkCI@v1 with: smalltalk-image: ${{ matrix.smalltalk }} diff --git a/.github/workflows/loading-gs64-components.yml b/.github/workflows/loading-gs64-components.yml new file mode 100644 index 0000000..6357a4a --- /dev/null +++ b/.github/workflows/loading-gs64-components.yml @@ -0,0 +1,21 @@ +name: 'GS64 Components Loading' +on: + - push + - pull_request + - workflow_dispatch +jobs: + component-loading: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + load-spec: + - Deployment + name: GS64 + ${{ matrix.load-spec }} + steps: + - uses: actions/checkout@v3 + - name: Load component in image + uses: ba-st-actions/gs64-ci@v2 + with: + project_name: 'Stargate-Consul' + load_spec: 'Stargate-Consul-${{ matrix.load-spec }}' diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index fbb50fa..84e4633 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -1,11 +1,14 @@ name: Markdown Lint -on: [push,pull_request,workflow_dispatch] +on: + - push + - pull_request + - workflow_dispatch jobs: remark-lint: name: runner / markdownlint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: markdownlint uses: reviewdog/action-markdownlint@v0 with: diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml index bfe0828..b43382e 100644 --- a/.github/workflows/notify.yml +++ b/.github/workflows/notify.yml @@ -1,9 +1,5 @@ name: Release Notifications - -on: - release: - types: [published] - +on: workflow_dispatch jobs: notify: runs-on: ubuntu-latest diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 6fe7559..38b6674 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -1,12 +1,13 @@ name: Shellcheck - -on: [push,pull_request] - +on: + - push + - pull_request + - workflow_dispatch jobs: shellcheck: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run Shellcheck uses: reviewdog/action-shellcheck@v1 with: diff --git a/.github/workflows/unit-tests-gs64.yml b/.github/workflows/unit-tests-gs64.yml new file mode 100644 index 0000000..dfae312 --- /dev/null +++ b/.github/workflows/unit-tests-gs64.yml @@ -0,0 +1,16 @@ +name: 'GS64 Unit Tests' +on: + - push + - pull_request + - workflow_dispatch +jobs: + unit-tests: + runs-on: ubuntu-latest + name: GS64 Unit Tests + steps: + - uses: actions/checkout@v4 + - name: Load Image and Run Tests + uses: ba-st-actions/gs64-ci@v2 + with: + project_name: 'Stargate-Consul' + run_tests: 'true' diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6383768..3e1d1c4 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,17 +1,20 @@ name: Unit Tests - -on: [push,pull_request,workflow_dispatch] - +on: + - push + - pull_request + - workflow_dispatch jobs: build: runs-on: ubuntu-latest strategy: matrix: - smalltalk: [ Pharo64-11, Pharo64-10, Pharo64-9.0, Pharo64-8.0 ] + smalltalk: + - Pharo64-10 + - Pharo64-11 name: ${{ matrix.smalltalk }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: hpi-swa/setup-smalltalkCI@v1 with: smalltalk-image: ${{ matrix.smalltalk }} diff --git a/LICENSE b/LICENSE index 5fa1cd4..3a3c3e9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2022 Buenos Aires Smalltalk Contributors +Copyright (c) 2020-2024 Buenos Aires Smalltalk Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 8d77cab..af9f546 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,23 @@ This library provides a [Stargate](https://github.com/ba-st/Stargate) operational plugin to interact with the [Consul](https://www.consul.io) HTTP API. -[![Unit Tests](https://github.com/ba-st/Stargate-Consul/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/unit-tests.yml) +[![Pharo Unit Tests](https://github.com/ba-st/Stargate-Consul/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/unit-tests.yml) +[![GS64 - Unit Tests](https://github.com/ba-st/Stargate-Consul/actions/workflows/unit-tests-gs64.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/unit-tests-gs64.yml) [![Coverage Status](https://codecov.io/github/ba-st/Stargate-Consul/coverage.svg?branch=release-candidate)](https://codecov.io/gh/ba-st/Stargate-Consul/branch/release-candidate) + [![Baseline Groups](https://github.com/ba-st/Stargate-Consul/actions/workflows/loading-groups.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/loading-groups.yml) +[![GS64 Components](https://github.com/ba-st/Stargate-Consul/actions/workflows/loading-gs64-components.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/loading-gs64-components.yml) [![Integration Tests](https://github.com/ba-st/Stargate-Consul/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/integration-tests.yml) [![Markdown Lint](https://github.com/ba-st/Stargate-Consul/actions/workflows/markdown-lint.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/markdown-lint.yml) [![Shellcheck](https://github.com/ba-st/Stargate-Consul/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/ba-st/Stargate-Consul/actions/workflows/shellcheck.yml) [![GitHub release](https://img.shields.io/github/release/ba-st/Stargate-Consul.svg)](https://github.com/ba-st/Stargate-Consul/releases/latest) -[![Pharo 8.0](https://img.shields.io/badge/Pharo-8.0-informational)](https://pharo.org) -[![Pharo 9.0](https://img.shields.io/badge/Pharo-9.0-informational)](https://pharo.org) + [![Pharo 10](https://img.shields.io/badge/Pharo-10-informational)](https://pharo.org) [![Pharo 11](https://img.shields.io/badge/Pharo-11-informational)](https://pharo.org) +[![GS64 3.7.0](https://img.shields.io/badge/GS64-3.7.0-informational)](https://gemtalksystems.com/products/gs64/) + Quick links - [**Explore the docs**](docs/README.md) diff --git a/docker/Dockerfile b/docker/Dockerfile index bee76a1..f21804b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,20 +7,14 @@ RUN pharo metacello install gitlocal://. \ BaselineOfStargateConsul --groups=Examples # Stage 2: Copy the resulting Pharo.image -FROM ghcr.io/ba-st/launchpad:v4 +FROM ghcr.io/ba-st/launchpad:v5 -USER root +COPY --from=loader --chown=pharo:users --chmod=755 /opt/pharo/pharo-local/iceberg/ba-st/Stargate/docker/health-check.sh ./ +COPY --from=loader --chown=pharo:users /opt/pharo/Pharo.image ./ +COPY --from=loader --chown=pharo:users /opt/pharo/Pharo.changes ./ +COPY --from=loader --chown=pharo:users /opt/pharo/Pharo*.sources ./ -COPY --from=loader /opt/pharo/pharo-local/iceberg/ba-st/Stargate/docker/health-check.sh ./ -COPY --from=loader /opt/pharo/Pharo.image ./ -COPY --from=loader /opt/pharo/Pharo.changes ./ -COPY --from=loader /opt/pharo/Pharo*.sources ./ - -RUN mkdir logs \ - && chmod a+x health-check.sh \ - && chown --recursive pharo:users /opt/pharo - -USER pharo +RUN mkdir logs HEALTHCHECK CMD ./health-check.sh diff --git a/rowan/components/Deployment.ston b/rowan/components/Deployment.ston new file mode 100644 index 0000000..6dd80fd --- /dev/null +++ b/rowan/components/Deployment.ston @@ -0,0 +1,20 @@ +RwSimpleProjectLoadComponentV2 { + #name : 'Deployment', + #projectNames : [ + 'Stargate', + 'Superluminal' + ], + #componentNames : [ ], + #packageNames : [ + 'Stargate-Consul' + ], + #conditionalPackageMapSpecs : { + 'gemstone' : { + 'allusers' : { + #packageNameToPlatformPropertiesMap : { + 'Stargate-Consul' : { 'symbolDictName' : 'Stargate' } + } + } + } + } +} diff --git a/rowan/components/Tests.ston b/rowan/components/Tests.ston new file mode 100644 index 0000000..9f55136 --- /dev/null +++ b/rowan/components/Tests.ston @@ -0,0 +1,21 @@ +RwSimpleProjectLoadComponentV2 { + #name : 'Tests', + #condition : 'tests', + #projectNames : [ ], + #componentNames : [ + 'Deployment' + ], + #packageNames : [ + 'Stargate-Consul-Tests' + + ], + #conditionalPackageMapSpecs : { + 'gemstone' : { + 'allusers' : { + #packageNameToPlatformPropertiesMap : { + 'Stargate-Consul-Tests' : { 'symbolDictName' : 'Stargate' } + } + } + } + } +} diff --git a/rowan/project.ston b/rowan/project.ston new file mode 100644 index 0000000..3982a02 --- /dev/null +++ b/rowan/project.ston @@ -0,0 +1,11 @@ +RwProjectSpecificationV2 { + #specName : 'project', + #projectSpecPath : 'rowan', + #componentsPath : 'rowan/components', + #packagesPath : 'source', + #projectsPath : 'rowan/projects', + #specsPath : 'rowan/specs', + #packageFormat : 'tonel', + #packageConvention : 'Rowan', + #comment : 'Stargate Consul project specification' +} diff --git a/rowan/projects/Stargate.ston b/rowan/projects/Stargate.ston new file mode 100644 index 0000000..636d66d --- /dev/null +++ b/rowan/projects/Stargate.ston @@ -0,0 +1,11 @@ +RwLoadSpecificationV2 { + #specName: 'Stargate', + #projectName : 'Stargate', + #gitUrl : 'https://github.com/ba-st/Stargate.git', + #revision : 'v9', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Deployment', + 'Dependent-SUnit-Extensions' + ] +} diff --git a/rowan/projects/Superluminal.ston b/rowan/projects/Superluminal.ston new file mode 100644 index 0000000..3423a94 --- /dev/null +++ b/rowan/projects/Superluminal.ston @@ -0,0 +1,11 @@ +RwLoadSpecificationV2 { + #specName: 'Superluminal', + #projectName : 'Superluminal', + #gitUrl : 'https://github.com/ba-st/Superluminal.git', + #revision : 'v5', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'API-Client', + 'Dependent-SUnit-Extensions' + ] +} diff --git a/rowan/specs/Stargate-Consul-CI.ston b/rowan/specs/Stargate-Consul-CI.ston new file mode 100644 index 0000000..d2a8e4e --- /dev/null +++ b/rowan/specs/Stargate-Consul-CI.ston @@ -0,0 +1,14 @@ +RwLoadSpecificationV2 { + #specName: 'Stargate-Consul-CI', + #projectName : 'Stargate-Consul', + #diskUrl : 'Stargate-Consul', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Tests' + ], + #customConditionalAttributes : [ + 'tests', + 'sunit' + ], + #comment : 'Loading spec for the continuous integration setup' +} diff --git a/rowan/specs/Stargate-Consul-Deployment.ston b/rowan/specs/Stargate-Consul-Deployment.ston new file mode 100644 index 0000000..86b95d0 --- /dev/null +++ b/rowan/specs/Stargate-Consul-Deployment.ston @@ -0,0 +1,9 @@ +RwLoadSpecificationV2 { + #specName: 'Stargate-Consul-Deployment', + #projectName : 'Stargate-Consul', + #diskUrl : 'Stargate-Consul', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Deployment' + ] +} diff --git a/source/.properties b/source/.properties index 53a5454..f668380 100644 --- a/source/.properties +++ b/source/.properties @@ -1,3 +1,4 @@ { - #format : #tonel + #format : #tonel, + #convention : 'Rowan' } From e7ac7ee647979ecf0592bd730cbe450e5bc93979 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 14:18:23 -0300 Subject: [PATCH 02/13] Update dependency versions --- .../BaselineOfStargateConsul.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/BaselineOfStargateConsul/BaselineOfStargateConsul.class.st b/source/BaselineOfStargateConsul/BaselineOfStargateConsul.class.st index 3ef9db9..fd5ac3e 100644 --- a/source/BaselineOfStargateConsul/BaselineOfStargateConsul.class.st +++ b/source/BaselineOfStargateConsul/BaselineOfStargateConsul.class.st @@ -30,17 +30,17 @@ BaselineOfStargateConsul >> projectClass [ BaselineOfStargateConsul >> setUpDependencies: spec [ spec - baseline: 'Stargate' with: [ spec repository: 'github://ba-st/Stargate:v8' ]; + baseline: 'Stargate' with: [ spec repository: 'github://ba-st/Stargate:v9' ]; project: 'Stargate-Deployment' copyFrom: 'Stargate' with: [ spec loads: 'Deployment' ]; project: 'Stargate-SUnit' copyFrom: 'Stargate' with: [ spec loads: 'Dependent-SUnit-Extensions' ]; project: 'Stargate-Tools' copyFrom: 'Stargate' with: [ spec loads: 'Tools' ]. spec - baseline: 'Launchpad' with: [ spec repository: 'github://ba-st/Launchpad:v4' ]; + baseline: 'Launchpad' with: [ spec repository: 'github://ba-st/Launchpad:v5' ]; project: 'Launchpad-Deployment' copyFrom: 'Launchpad' with: [ spec loads: 'Deployment' ]. spec - baseline: 'Superluminal' with: [ spec repository: 'github://ba-st/Superluminal:v4' ]; + baseline: 'Superluminal' with: [ spec repository: 'github://ba-st/Superluminal:v5' ]; project: 'Superluminal-API-Client' copyFrom: 'Superluminal' with: [ spec loads: 'API Client' ] ] From f2db4f95329e9bcae20346a08461208481c594b6 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 16:00:06 -0300 Subject: [PATCH 03/13] Fix compatibility with updated dependencies --- .../StargateConsulExampleTest.class.st | 14 ++++++++------ .../StargateConsulExample.class.st | 12 ++++++------ .../ConsulAgentDockerBasedCheckTest.class.st | 18 ++++++++++-------- .../ConsulAgentHTTPBasedCheckTest.class.st | 19 ++++++++++--------- .../ConsulAwareStargateApplication.class.st | 8 +++++--- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st index 1cbb8e8..d304a4b 100644 --- a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st +++ b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st @@ -51,12 +51,6 @@ StargateConsulExampleTest >> tearDown [ super tearDown ] -{ #category : #tests } -StargateConsulExampleTest >> testApplicationBaselineName [ - - self assert: StargateConsulExample applicationBaselineName equals: #BaselineOfStargateConsul -] - { #category : #tests } StargateConsulExampleTest >> testDefaultServiceDiscoveryTimeSlotBetweenRetries [ @@ -105,6 +99,14 @@ ENVIRONMENT ' expandMacrosWith: StargateConsulExample version ) ] +{ #category : #tests } +StargateConsulExampleTest >> testProjectName [ + + self + assert: StargateConsulExample projectName + equals: 'StargateConsul' +] + { #category : #tests } StargateConsulExampleTest >> testStart [ diff --git a/source/Stargate-Consul-Examples/StargateConsulExample.class.st b/source/Stargate-Consul-Examples/StargateConsulExample.class.st index e590663..4c065f8 100644 --- a/source/Stargate-Consul-Examples/StargateConsulExample.class.st +++ b/source/Stargate-Consul-Examples/StargateConsulExample.class.st @@ -4,12 +4,6 @@ Class { #category : #'Stargate-Consul-Examples' } -{ #category : #private } -StargateConsulExample class >> applicationBaselineName [ - - ^ #BaselineOfStargateConsul -] - { #category : #accessing } StargateConsulExample class >> commandName [ @@ -29,6 +23,12 @@ StargateConsulExample class >> initialize [ self initializeVersion ] +{ #category : #private } +StargateConsulExample class >> projectName [ + + ^ 'StargateConsul' +] + { #category : #'private - accessing' } StargateConsulExample >> controllersToInstall [ diff --git a/source/Stargate-Consul-Tests/ConsulAgentDockerBasedCheckTest.class.st b/source/Stargate-Consul-Tests/ConsulAgentDockerBasedCheckTest.class.st index 6468795..6ceba1e 100644 --- a/source/Stargate-Consul-Tests/ConsulAgentDockerBasedCheckTest.class.st +++ b/source/Stargate-Consul-Tests/ConsulAgentDockerBasedCheckTest.class.st @@ -11,20 +11,22 @@ Class { ConsulAgentDockerBasedCheckTest >> testAsJSON [ | check json | - check := ConsulAgentDockerBasedCheck - named: 'Check memory' - executing: '/bin/bash' - withArguments: #('/usr/local/bin/check-memory.sh') - inContainer: 'f972c95ebf0e' - every: 10 seconds. + named: 'Check memory' + executing: '/bin/bash' + withArguments: #( '/usr/local/bin/check-memory.sh' ) + inContainer: 'f972c95ebf0e' + every: 10 seconds. - json := NeoJSONObject fromString: ( NeoJSONWriter toStringPretty: check ). + json := NeoJSONObject fromString: + (NeoJSONWriter toStringPretty: check). self assert: json Name equals: 'Check memory'; assert: json Shell equals: '/bin/bash'; - assert: json Args equals: #('/usr/local/bin/check-memory.sh'); + withTheOnlyOneIn: json Args + do: [ :arg | + self assert: arg equals: '/usr/local/bin/check-memory.sh' ]; assert: json DockerContainerID equals: 'f972c95ebf0e'; assert: json Interval equals: '10s' ] diff --git a/source/Stargate-Consul-Tests/ConsulAgentHTTPBasedCheckTest.class.st b/source/Stargate-Consul-Tests/ConsulAgentHTTPBasedCheckTest.class.st index 83727d8..5d0308b 100644 --- a/source/Stargate-Consul-Tests/ConsulAgentHTTPBasedCheckTest.class.st +++ b/source/Stargate-Consul-Tests/ConsulAgentHTTPBasedCheckTest.class.st @@ -35,21 +35,22 @@ ConsulAgentHTTPBasedCheckTest >> testAsJSON [ ConsulAgentHTTPBasedCheckTest >> testAsJSONWhenHeadersArePresent [ | check json | - check := ConsulAgentHTTPBasedCheck - named: 'HTTP check' - executing: #POST - against: 'http://api.example.com' asUrl - withHeaders: { #accept -> ZnMimeType applicationJson } - every: 10 seconds - timeoutAfter: 1.5 minutes. + named: 'HTTP check' + executing: #POST + against: 'http://api.example.com' asUrl + withHeaders: { #accept -> ZnMimeType applicationJson } + every: 10 seconds + timeoutAfter: 1.5 minutes. - json := NeoJSONObject fromString: ( NeoJSONWriter toStringPretty: check ). + json := NeoJSONObject fromString: + (NeoJSONWriter toStringPretty: check). self assert: json Name equals: 'HTTP check'; assert: json Method equals: 'POST'; - assert: json Header accept equals: #('application/json'); + withTheOnlyOneIn: json Header accept + do: [ :header | self assert: header equals: 'application/json' ]; assert: json HTTP equals: 'http://api.example.com/'; assert: json Timeout equals: '1m30s'; assert: json Interval equals: '10s' diff --git a/source/Stargate-Consul/ConsulAwareStargateApplication.class.st b/source/Stargate-Consul/ConsulAwareStargateApplication.class.st index 3631c23..cb4c754 100644 --- a/source/Stargate-Consul/ConsulAwareStargateApplication.class.st +++ b/source/Stargate-Consul/ConsulAwareStargateApplication.class.st @@ -118,7 +118,7 @@ ConsulAwareStargateApplication >> healthCheckToken [ jws payload: ( JWTClaimsSet new permissions: #( 'execute:health-check' ); yourself ). - jws key: self stargateConfiguration operationsSecret. + jws symmetricKey: self stargateConfiguration operationsSecret. ^ jws compactSerialized ] @@ -162,8 +162,10 @@ ConsulAwareStargateApplication >> serviceDiscoveryTimeSlotBetweenRetries [ { #category : #'private - building' } ConsulAwareStargateApplication >> withDockerHostnameDo: aFoundBlock ifAbsent: aNotFoundBlock [ - "Inside Docker containers the HOSTNAME variable holds the container id" - ^ OSEnvironment current at: 'HOSTNAME' ifPresent: aFoundBlock ifAbsent: aNotFoundBlock + ^ LanguagePlatform current os + environmentAt: 'HOSTNAME' + ifPresent: aFoundBlock + ifAbsent: aNotFoundBlock ] From 44bc042be04a8a847b6225e79da4905859802211 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 16:05:08 -0300 Subject: [PATCH 04/13] Update actions version --- .github/workflows/loading-gs64-components.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/loading-gs64-components.yml b/.github/workflows/loading-gs64-components.yml index 6357a4a..6f3cfeb 100644 --- a/.github/workflows/loading-gs64-components.yml +++ b/.github/workflows/loading-gs64-components.yml @@ -13,7 +13,7 @@ jobs: - Deployment name: GS64 + ${{ matrix.load-spec }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Load component in image uses: ba-st-actions/gs64-ci@v2 with: From 446e113e8b09e1af1ae8e4e335be1b9f50ba6e66 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 16:05:43 -0300 Subject: [PATCH 05/13] Use LogRecord --- source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st b/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st index c5756b2..d9c3d8b 100644 --- a/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st +++ b/source/Stargate-Consul/ConsulServiceDiscoveryPlugin.class.st @@ -109,7 +109,7 @@ ConsulServiceDiscoveryPlugin >> initializeWith: configurationOptions [ { #category : #private } ConsulServiceDiscoveryPlugin >> logDeregistrationFailedAtAttempt: attemptNumber dueTo: error [ - LaunchpadLogRecord emitError: + LogRecord emitError: ('Attempt #<1p>/<2p> to deregister service in Consul Agent failed: <3s>' expandMacrosWith: attemptNumber with: self retryCount + 1 @@ -119,7 +119,7 @@ ConsulServiceDiscoveryPlugin >> logDeregistrationFailedAtAttempt: attemptNumber { #category : #private } ConsulServiceDiscoveryPlugin >> logRegistrationFailedAtAttempt: attemptNumber dueTo: error [ - LaunchpadLogRecord emitError: + LogRecord emitError: ('Attempt #<1p>/<2p> to register service in Consul Agent failed: <3s>' expandMacrosWith: attemptNumber with: self retryCount + 1 From 7f77a682386a1320f7ec3eb5671cebbe2ea1f03a Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 17:11:18 -0300 Subject: [PATCH 06/13] Fix spelling typo --- source/Stargate-Consul/ConsulAgentCheck.class.st | 4 ++-- .../ConsulAgentDockerBasedCheck.class.st | 8 ++++---- .../Stargate-Consul/ConsulAgentHTTPBasedCheck.class.st | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/Stargate-Consul/ConsulAgentCheck.class.st b/source/Stargate-Consul/ConsulAgentCheck.class.st index 2cf2d37..edc3b7e 100644 --- a/source/Stargate-Consul/ConsulAgentCheck.class.st +++ b/source/Stargate-Consul/ConsulAgentCheck.class.st @@ -13,7 +13,7 @@ ConsulAgentCheck >> asDictionary [ ^ Dictionary new at: 'Name' put: self name; - at: 'Interval' put: ( self asGoTimeFormat: self invokationInterval ); + at: 'Interval' put: ( self asGoTimeFormat: self invocationInterval ); yourself ] @@ -36,7 +36,7 @@ ConsulAgentCheck >> asGoTimeFormat: aDuration [ ] { #category : #accessing } -ConsulAgentCheck >> invokationInterval [ +ConsulAgentCheck >> invocationInterval [ ^ self subclassResponsibility ] diff --git a/source/Stargate-Consul/ConsulAgentDockerBasedCheck.class.st b/source/Stargate-Consul/ConsulAgentDockerBasedCheck.class.st index f2b70d5..77b029c 100644 --- a/source/Stargate-Consul/ConsulAgentDockerBasedCheck.class.st +++ b/source/Stargate-Consul/ConsulAgentDockerBasedCheck.class.st @@ -12,7 +12,7 @@ Class { 'shell', 'arguments', 'containerId', - 'invokationInterval' + 'invocationInterval' ], #category : #'Stargate-Consul' } @@ -57,13 +57,13 @@ ConsulAgentDockerBasedCheck >> initializeNamed: aName executing: aCommand withAr shell := aCommand. arguments := anArgumentArray. containerId := aContainerId. - invokationInterval := aDuration + invocationInterval := aDuration ] { #category : #accessing } -ConsulAgentDockerBasedCheck >> invokationInterval [ +ConsulAgentDockerBasedCheck >> invocationInterval [ - ^ invokationInterval + ^ invocationInterval ] { #category : #accessing } diff --git a/source/Stargate-Consul/ConsulAgentHTTPBasedCheck.class.st b/source/Stargate-Consul/ConsulAgentHTTPBasedCheck.class.st index 2b0f661..fcaa7df 100644 --- a/source/Stargate-Consul/ConsulAgentHTTPBasedCheck.class.st +++ b/source/Stargate-Consul/ConsulAgentHTTPBasedCheck.class.st @@ -9,8 +9,8 @@ Class { 'url', 'method', 'headers', - 'invokationInterval', - 'timeout' + 'timeout', + 'invocationInterval' ], #category : #'Stargate-Consul' } @@ -74,14 +74,14 @@ ConsulAgentHTTPBasedCheck >> initializeNamed: aName executing: anHttpMethod agai method := anHttpMethod. url := anUrl. self initializeHeadersBasedOn: aHeaderCollection. - invokationInterval := aDuration. + invocationInterval := aDuration. timeout := timeoutDuration ] { #category : #accessing } -ConsulAgentHTTPBasedCheck >> invokationInterval [ +ConsulAgentHTTPBasedCheck >> invocationInterval [ - ^ invokationInterval + ^ invocationInterval ] { #category : #accessing } From 34fff4060ee9b6b43b0f65f5aba983c863a62487 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 28 Feb 2024 17:19:56 -0300 Subject: [PATCH 07/13] Fix spelling mistake --- docs/MigrationGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/MigrationGuide.md b/docs/MigrationGuide.md index e7bb125..a602b9c 100644 --- a/docs/MigrationGuide.md +++ b/docs/MigrationGuide.md @@ -3,7 +3,7 @@ ## Migration from v2 to v3 - Pharo 7 support is now deprecated, use Pharo 8 or 9. -- Dependencies udpated: +- Dependencies updated: - [`Launchpad`](https://github.com/ba-st/Launchpad) was updated to v4 - [`Stargate`](https://github.com/ba-st/Stargate) was updated to v7 - [`Superluminal`](https://github.com/ba-st/Superluminal) was updated to v3 From 735226d6c6678ba80c19e242e8a4916a1b9bbe59 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 29 Feb 2024 10:00:56 -0300 Subject: [PATCH 08/13] Improve GS64 compatibility --- source/Stargate-Consul/ConsulAgentCheck.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Stargate-Consul/ConsulAgentCheck.class.st b/source/Stargate-Consul/ConsulAgentCheck.class.st index edc3b7e..972ed2d 100644 --- a/source/Stargate-Consul/ConsulAgentCheck.class.st +++ b/source/Stargate-Consul/ConsulAgentCheck.class.st @@ -28,7 +28,7 @@ ConsulAgentCheck >> asGoTimeFormat: aDuration [ self nextPut: aDuration hours of: 'h' in: stream; nextPut: aDuration minutes of: 'm' in: stream; - nextPut: aDuration seconds of: 's' in: stream; + nextPut: aDuration asSeconds of: 's' in: stream; nextPut: aDuration wholeMilliseconds of: 'ms' in: stream; nextPut: aDuration wholeMicroseconds of: 'us' in: stream; nextPut: aDuration wholeNanoseconds of: 'ns' in: stream From 7f158991635847003aaa3a803d16642e3ed5d449 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 29 Feb 2024 10:03:53 -0300 Subject: [PATCH 09/13] Fix asGoTimeFormat: for GS64 --- source/Stargate-Consul/ConsulAgentCheck.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Stargate-Consul/ConsulAgentCheck.class.st b/source/Stargate-Consul/ConsulAgentCheck.class.st index 972ed2d..dbf16b3 100644 --- a/source/Stargate-Consul/ConsulAgentCheck.class.st +++ b/source/Stargate-Consul/ConsulAgentCheck.class.st @@ -28,7 +28,7 @@ ConsulAgentCheck >> asGoTimeFormat: aDuration [ self nextPut: aDuration hours of: 'h' in: stream; nextPut: aDuration minutes of: 'm' in: stream; - nextPut: aDuration asSeconds of: 's' in: stream; + nextPut: aDuration seconds truncated of: 's' in: stream; nextPut: aDuration wholeMilliseconds of: 'ms' in: stream; nextPut: aDuration wholeMicroseconds of: 'us' in: stream; nextPut: aDuration wholeNanoseconds of: 'ns' in: stream From 6145f0f163a0d6827716e80fb0434935f10f9c30 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 29 Feb 2024 11:00:55 -0300 Subject: [PATCH 10/13] Add Examples component --- .github/workflows/loading-gs64-components.yml | 1 + rowan/components/Examples.ston | 19 +++++++++++++++++++ rowan/components/Tests.ston | 9 ++++++--- rowan/specs/Stargate-Consul-Examples.ston | 9 +++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 rowan/components/Examples.ston create mode 100644 rowan/specs/Stargate-Consul-Examples.ston diff --git a/.github/workflows/loading-gs64-components.yml b/.github/workflows/loading-gs64-components.yml index 6f3cfeb..7052b81 100644 --- a/.github/workflows/loading-gs64-components.yml +++ b/.github/workflows/loading-gs64-components.yml @@ -11,6 +11,7 @@ jobs: matrix: load-spec: - Deployment + - Examples name: GS64 + ${{ matrix.load-spec }} steps: - uses: actions/checkout@v4 diff --git a/rowan/components/Examples.ston b/rowan/components/Examples.ston new file mode 100644 index 0000000..402086f --- /dev/null +++ b/rowan/components/Examples.ston @@ -0,0 +1,19 @@ +RwSimpleProjectLoadComponentV2 { + #name : 'Examples', + #projectNames : [ ], + #componentNames : [ + 'Deployment' + ], + #packageNames : [ + 'Stargate-Consul-Examples' + ], + #conditionalPackageMapSpecs : { + 'gemstone' : { + 'allusers' : { + #packageNameToPlatformPropertiesMap : { + 'Stargate-Consul-Examples' : { 'symbolDictName' : 'Stargate' } + } + } + } + } +} diff --git a/rowan/components/Tests.ston b/rowan/components/Tests.ston index 9f55136..7b41133 100644 --- a/rowan/components/Tests.ston +++ b/rowan/components/Tests.ston @@ -3,17 +3,20 @@ RwSimpleProjectLoadComponentV2 { #condition : 'tests', #projectNames : [ ], #componentNames : [ - 'Deployment' + 'Deployment', + 'Examples' ], #packageNames : [ - 'Stargate-Consul-Tests' + 'Stargate-Consul-Tests', + 'Stargate-Consul-Examples-Tests' ], #conditionalPackageMapSpecs : { 'gemstone' : { 'allusers' : { #packageNameToPlatformPropertiesMap : { - 'Stargate-Consul-Tests' : { 'symbolDictName' : 'Stargate' } + 'Stargate-Consul-Tests' : { 'symbolDictName' : 'Stargate' }, + 'Stargate-Consul-Examples-Tests' : { 'symbolDictName' : 'Stargate' } } } } diff --git a/rowan/specs/Stargate-Consul-Examples.ston b/rowan/specs/Stargate-Consul-Examples.ston new file mode 100644 index 0000000..ca6a2fd --- /dev/null +++ b/rowan/specs/Stargate-Consul-Examples.ston @@ -0,0 +1,9 @@ +RwLoadSpecificationV2 { + #specName: 'Stargate-Consul-Examples', + #projectName : 'Stargate-Consul', + #diskUrl : 'Stargate-Consul', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Examples' + ] +} From e244b64b6d71fe612706e07e0a3ce165d5b99367 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 29 Feb 2024 11:03:48 -0300 Subject: [PATCH 11/13] Fix StargateConsulExampleTest>>#tearDown to compile in GS64 --- .../StargateConsulExampleTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st index d304a4b..2c0e03f 100644 --- a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st +++ b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st @@ -47,7 +47,7 @@ StargateConsulExampleTest >> start: aLaunchpadApplication withAll: arguments [ { #category : #running } StargateConsulExampleTest >> tearDown [ - application ifNotNil: #stop. + application ifNotNil: [ application stop ]. super tearDown ] From 9ce3c082397ffe0f82d08702b98dace2f2643470 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 29 Feb 2024 13:43:25 -0300 Subject: [PATCH 12/13] Fix project name for GS compatibility --- .../StargateConsulExampleTest.class.st | 2 +- source/Stargate-Consul-Examples/StargateConsulExample.class.st | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st index 2c0e03f..350741c 100644 --- a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st +++ b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st @@ -104,7 +104,7 @@ StargateConsulExampleTest >> testProjectName [ self assert: StargateConsulExample projectName - equals: 'StargateConsul' + equals: 'Stargate-Consul' ] { #category : #tests } diff --git a/source/Stargate-Consul-Examples/StargateConsulExample.class.st b/source/Stargate-Consul-Examples/StargateConsulExample.class.st index 4c065f8..e40fd63 100644 --- a/source/Stargate-Consul-Examples/StargateConsulExample.class.st +++ b/source/Stargate-Consul-Examples/StargateConsulExample.class.st @@ -26,7 +26,7 @@ StargateConsulExample class >> initialize [ { #category : #private } StargateConsulExample class >> projectName [ - ^ 'StargateConsul' + ^ 'Stargate-Consul' ] { #category : #'private - accessing' } From 4a75413178df2424ad92ec7b89e0c8fe4d1d3511 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 29 Feb 2024 14:54:29 -0300 Subject: [PATCH 13/13] Improve tests portability --- .../StargateConsulExampleTest.class.st | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st index 350741c..38ade5b 100644 --- a/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st +++ b/source/Stargate-Consul-Examples-Tests/StargateConsulExampleTest.class.st @@ -70,33 +70,7 @@ StargateConsulExampleTest >> testPrintHelpOn [ help := String streamContents: [ :stream | StargateConsulExample printHelpOn: stream ]. - self assert: help equals: ( 'NAME - stargate-consul-example [<1s>] - I provide a RESTful API over HTTP -SYNOPSYS - stargate-consul-example --stargate.public-url=% --stargate.port=% --stargate.operations-secret=% --stargate.consul-agent-location=% [--stargate.scheme=%] -PARAMETERS - --stargate.public-url=% - Public URL where the API is deployed. Used to create hypermedia links. - --stargate.port=% - Listening port. - --stargate.operations-secret=% - Secret key for checking JWT signatures. - --stargate.consul-agent-location=% - Location of the Consul Agent. Leave empty to disable the plugin. - --stargate.scheme=% - Transport scheme. It''s used to configure Consul HTTP checks. Defaults to http. -ENVIRONMENT - STARGATE__PUBLIC_URL - Public URL where the API is deployed. Used to create hypermedia links. - STARGATE__PORT - Listening port. - STARGATE__OPERATIONS_SECRET - Secret key for checking JWT signatures. - STARGATE__CONSUL_AGENT_LOCATION - Location of the Consul Agent. Leave empty to disable the plugin. - STARGATE__SCHEME - Transport scheme. It''s used to configure Consul HTTP checks. Defaults to http. -' expandMacrosWith: StargateConsulExample version ) + self assert: help equals: ( 'NAMEstargate-consul-example [<1s>] - I provide a RESTful API over HTTPSYNOPSYSstargate-consul-example --stargate.public-url=% --stargate.port=% --stargate.operations-secret=% --stargate.consul-agent-location=% [--stargate.scheme=%]PARAMETERS--stargate.public-url=%Public URL where the API is deployed. Used to create hypermedia links.--stargate.port=%Listening port.--stargate.operations-secret=%Secret key for checking JWT signatures.--stargate.consul-agent-location=%Location of the Consul Agent. Leave empty to disable the plugin.--stargate.scheme=%Transport scheme. It''s used to configure Consul HTTP checks. Defaults to http.ENVIRONMENTSTARGATE__PUBLIC_URLPublic URL where the API is deployed. Used to create hypermedia links.STARGATE__PORTListening port.STARGATE__OPERATIONS_SECRETSecret key for checking JWT signatures.STARGATE__CONSUL_AGENT_LOCATIONLocation of the Consul Agent. Leave empty to disable the plugin.STARGATE__SCHEMETransport scheme. It''s used to configure Consul HTTP checks. Defaults to http.' expandMacrosWith: StargateConsulExample version ) ] { #category : #tests }