Automatically create API spec #2
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
# | |
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH | |
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation | |
# | |
# See the NOTICE file(s) distributed with this work for additional | |
# information regarding copyright ownership. | |
# | |
# This program and the accompanying materials are made available under the | |
# terms of the Apache License, Version 2.0 which is available at | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
# License for the specific language governing permissions and limitations | |
# under the License. | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# | |
--- | |
name: "Verify" | |
on: | |
workflow_call: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
verify-license-headers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- name: "Check for files without a license header" | |
run: |- | |
# checks all java, yaml, kts and sql files for an Apache 2.0 license header | |
cmd="grep -riL \"SPDX-License-Identifier: Apache-2.0\" --include=\*.{java,yaml,yml,kts,sql} --exclude-dir={.gradle,\*\openapi} ." | |
violations=$(eval $cmd | wc -l) | |
if [[ $violations -ne 0 ]] ; then | |
echo "$violations files without license headers were found:"; | |
eval $cmd; | |
exit 1; | |
fi | |
verify-helm-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: addnab/docker-run-action@v3 | |
with: | |
image: jnorwood/helm-docs:v1.10.0 | |
options: -v ${{ github.workspace }}/charts:/helm-docs | |
run: helm-docs | |
- run: | | |
if $(git diff --quiet --exit-code); then | |
echo "Helm chart docs up to date" | |
else | |
echo "Helm chart docs not up to date:" | |
git diff | |
exit 1 | |
fi | |
verify-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-java | |
- name: Download latest Eclipse Dash | |
run: | | |
curl -L https://repo.eclipse.org/service/local/artifact/maven/redirect\?r\=dash-licenses\&g\=org.eclipse.dash\&a\=org.eclipse.dash.licenses\&v\=LATEST --output dash.jar | |
- name: Regenerate DEPENDENCIES | |
run: | | |
# dash returns a nonzero exit code if there are libs that need review. the "|| true" avoids that | |
./gradlew allDependencies | grep -Poh "(?<=\s)[\w.-]+:[\w.-]+:[^:\s\[\]]+" | sort | uniq | java -jar dash.jar - -summary DEPENDENCIES-gen || true | |
# log warning if restricted deps are found | |
grep -E 'restricted' DEPENDENCIES | if test $(wc -l) -gt 0; then | |
echo "::warning file=DEPENDENCIES,title=Restricted Dependencies found::Some dependencies are marked 'restricted' - please review them" | |
fi | |
# log error and fail job if rejected deps are found | |
grep -E 'rejected' DEPENDENCIES | if test $(wc -l) -gt 0; then | |
echo "::error file=DEPENDENCIES,title=Rejected Dependencies found::Some dependencies are marked 'rejected', they cannot be used" | |
exit 1 | |
fi | |
- name: Check for differences | |
run: | | |
diff DEPENDENCIES DEPENDENCIES-gen | |
verify-formatting: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- uses: ./.github/actions/setup-java | |
- name: Verify proper formatting | |
run: ./gradlew spotlessCheck | |
- name: Run Checkstyle | |
run: | | |
./gradlew checkstyleMain checkstyleTest | |
markdown-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- name: Install mardkdownlint | |
run: npm install -g markdownlint-cli2 | |
- name: Run markdownlint | |
run: | | |
markdownlint-cli2-config .markdownlint.yaml "**/*.md" "#.github" "#charts" | |
unit-tests: | |
runs-on: ubuntu-latest | |
needs: [ verify-formatting, verify-license-headers ] | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- uses: ./.github/actions/setup-java | |
- name: Run Unit tests | |
run: ./gradlew test | |
integration-tests: | |
runs-on: ubuntu-latest | |
needs: [ verify-formatting, verify-license-headers ] | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- uses: ./.github/actions/setup-java | |
- name: Run Integration tests | |
run: ./gradlew test -DincludeTags="ComponentTest" | |
api-tests: | |
runs-on: ubuntu-latest | |
needs: [ verify-formatting, verify-license-headers ] | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- uses: ./.github/actions/setup-java | |
- name: Run API tests | |
run: ./gradlew test -DincludeTags="ApiTest" | |
end-to-end-tests: | |
runs-on: ubuntu-latest | |
needs: [ verify-formatting, verify-license-headers ] | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- uses: ./.github/actions/setup-java | |
- name: Run E2E tests | |
run: ./gradlew test -DincludeTags="EndToEndTest" | |
postgres-tests: | |
runs-on: ubuntu-latest | |
needs: [ verify-formatting, verify-license-headers ] | |
services: | |
postgres: | |
image: postgres:14.2 | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: password | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-java | |
# create non-default schema name to test usage of non-default schema | |
- name: setup postgres schema | |
run: | | |
sudo apt update | |
sudo apt install --yes postgresql-client | |
psql -h localhost -d postgres -U postgres -c 'CREATE SCHEMA testschema;' | |
env: | |
PGPASSWORD: password | |
- name: Run Postgresql E2E tests | |
run: ./gradlew test -DincludeTags="PostgresqlIntegrationTest" | |
miw-integration-tests: | |
runs-on: ubuntu-latest | |
needs: [ verify-formatting, verify-license-headers ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-java | |
- uses: actions/checkout@v2 | |
- name: Starting MIW, Keycloak and Postgres Servers | |
run: | | |
cd edc-tests/miw-tests/src/test/resources/docker-environment | |
docker compose up --wait | |
- uses: nick-fields/retry@v2 | |
name: Wait for MIW | |
with: | |
timeout_minutes: 5 | |
max_attempts: 3 | |
command: | | |
code=$(curl -IL -sw "%{http_code}" http://localhost:8000/api/actuator/health -o /dev/null) | |
if [ "$code" -ne "401" ]; then | |
echo "MIW not ready yet, status = $code" | |
exit 1; | |
fi | |
- name: Seed test data | |
run: | | |
docker exec docker-environment-postgres-1 /opt/seed.sh | |
- name: Run MIW Integration tests | |
run: | | |
./gradlew -p edc-tests/miw-tests test -DincludeTags="MiwIntegrationTest" -PverboseTest=true | |
- name: Run SSI E2E tests | |
run: | | |
pwd | |
./gradlew compileJava compileTestJava | |
./gradlew -p edc-tests/e2e-tests test -DincludeTags="MiwIntegrationTest" -PverboseTest=true | |
# this is for testing only; remove later | |
swagger-api: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/publish-swagger-api | |
with: | |
downstreamVersion: testing | |
upstreamVersion: 0.1.4-SNAPSHOT |