Skip to content

Commit

Permalink
Merge pull request #14 from FIWARE/merge-repos
Browse files Browse the repository at this point in the history
Merge with FIWARE-Ops data-space-connector repository
  • Loading branch information
Stefan Wiedemann authored Jul 29, 2024
2 parents d07bddc + a7d2850 commit d3bc9ea
Show file tree
Hide file tree
Showing 195 changed files with 25,412 additions and 64 deletions.
8 changes: 8 additions & 0 deletions .github/build/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

wget "https://get.helm.sh/helm-v3.15.2-linux-amd64.tar.gz"
tar zxf helm-v3.15.2-linux-amd64.tar.gz
mkdir bin
mv linux-amd64/helm ./bin/helm

go install github.com/yannh/kubeconform/cmd/kubeconform@latest
20 changes: 20 additions & 0 deletions .github/scripts/eval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash

CHARTS=$(pwd)/charts/*
RETURN_VAL=0
for chart in $CHARTS
do
./bin/helm dependency build ${chart}
./bin/helm template ${chart} | kubeconform -strict

ret=$?
if [ $ret -ne 0 ]; then
RETURN_VAL=$ret
fi
done

if [ $RETURN_VAL -eq 0 ]; then
echo "Chart evaluation successful !!!"
fi

exit $RETURN_VAL
7 changes: 7 additions & 0 deletions .github/scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

CHARTS=./charts/*
for chart in $CHARTS
do
docker run --rm -v $(pwd):/apps alpine/helm:2.9.0 lint $chart
done
173 changes: 173 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Check PR

on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
branches:
- main

jobs:

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Lint
run: ./.github/scripts/lint.sh

eval:
runs-on: ubuntu-latest
needs:
- lint

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v5
with:
go-version: '>=1.17.0'

- name: Eval
run: |
.github/build/install.sh
.github/scripts/eval.sh
check-labels:
runs-on: ubuntu-latest
needs:
- lint
- eval

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '11'
java-package: jdk

- id: match-label
name: Match semver labels
uses: zwaldowski/match-label-action@v1
with:
allowed: major, minor, patch

- uses: zwaldowski/semver-release-action@v2
name: Semver release
with:
dry_run: true
bump: ${{ steps.match-label.outputs.match }}
github_token: ${{ secrets.GITHUB_TOKEN }}

comment:
runs-on: ubuntu-latest
needs:
- "check-labels"

if: always()
steps:
- uses: technote-space/workflow-conclusion-action@v2
- name: Checkout
uses: actions/checkout@v1

- name: Comment PR
if: env.WORKFLOW_CONCLUSION == 'failure'
uses: thollander/[email protected]
with:
message: "Please apply one of the following labels to the PR: 'patch', 'minor', 'major'."
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

prepare-release:
needs: ["check-labels", "comment"]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- id: bump
uses: zwaldowski/match-label-action@v4
with:
allowed: major,minor,patch

- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]


# prepare yaml parser
- uses: actions/setup-go@v4
- name: Install yq
run: |
go install github.com/mikefarah/yq/v4@latest
yq --version
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Update versions
shell: bash
run: |
declare -A changedCharts
for file in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do
echo "$file was changed"
baseFolder=$(cut -d'/' -f1 <<< "$file")
if [ $baseFolder = "charts" ] && [ $file != "charts/README.md" ]; then
chartName=$(cut -d'/' -f2 <<< "$file")
changedCharts[$chartName]=$chartName
fi
done
for c in "${changedCharts[@]}"; do
# get version from chart yaml
version=$(yq e '.version' "charts/$c/Chart.yaml")
major=$(cut -d'.' -f1 <<< "$version")
minor=$(cut -d'.' -f2 <<< "$version")
patch=$(cut -d'.' -f3 <<< "$version")
prType=${{ steps.bump.outputs.match }}
echo Update version $version with type $prType
if [ $prType = "major" ]; then
echo Update major
major=$((major+1))
minor=0
patch=0
elif [ $prType = "minor" ]; then
echo Update minor
minor=$((minor+1))
patch=0
elif [ $prType = "patch" ]; then
echo Update patch
patch=$((patch+1))
fi
echo Update version to $major.$minor.$patch for $c
yq e -i '.version = "'$major.$minor.$patch'"' charts/$c/Chart.yaml
done
- name: Commit files
continue-on-error: true
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git status
echo commit
git commit -m "Update helm chart versions" -a
echo status update
git status
- name: Push changes
continue-on-error: true
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}
6 changes: 6 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ jobs:

- uses: actions/checkout@v2

- name: Generate Table of contents
uses: technote-space/toc-generator@v4
with:
TARGET_PATHS: "./README.md,./doc/README.md"
COMMIT_MESSAGE: "Update ToC"

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
122 changes: 91 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,104 @@ on:

jobs:

generate-version:
name: Generate version
runs-on: ubuntu-latest
generate-version:
name: "Generate version"
runs-on: ubuntu-latest

outputs:
version: ${{ steps.out.outputs.version }}
outputs:
version: ${{ steps.out.outputs.version }}

steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

- id: pr
uses: actions-ecosystem/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v1
with:
java-version: '17'
java-package: jdk

- uses: zwaldowski/semver-release-action@v2
with:
dry_run: true
bump: ${{ steps.pr.outputs.labels }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- id: pr
uses: actions-ecosystem/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Set version output
id: out
run: echo "::set-output name=version::$(echo ${VERSION})"
- name: Match semver label via bash
id: match-label-bash
run: |
LABELS=$(cat <<-END
${{ steps.pr.outputs.labels }}
END
)
IFS='\n' read -ra LABEL <<< "$LABELS"
for i in "${LABEL[@]}"; do
echo $i
case $i in
# Will just use the first occurence
'major'|'minor'|'patch')
echo "RELEASE_LABEL=$i" >> $GITHUB_OUTPUT
break
esac
done
- uses: zwaldowski/semver-release-action@v2
with:
dry_run: true
bump: ${{ steps.match-label-bash.outputs.RELEASE_LABEL }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Set version output
id: out
run: echo "::set-output name=version::$(echo ${VERSION})"

git-release:
name: Git Release
needs: ["generate-version"]
runs-on: ubuntu-latest
deploy:
name: "Release charts"
needs:
- "generate-version"
runs-on: ubuntu-latest

steps:
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v2
- name: Fetch history
run: git fetch --prune --unshallow

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
run: |
curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true

git-release:
name: "Create Git Release"
needs: ["generate-version", "deploy"]
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Generate Table of contents
uses: technote-space/toc-generator@v4
with:
TARGET_PATHS: "./README.md,./doc/README.md"
COMMIT_MESSAGE: "Update ToC"

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.generate-version.outputs.version }}
prerelease: false
title: ${{ needs.generate-version.outputs.version }}
files: |
LICENSE
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.generate-version.outputs.version }}
title: ${{ needs.generate-version.outputs.version }}
prerelease: false
20 changes: 20 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test
on:
push

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '17'
java-package: jdk

- name: Execute tests
id: test
run: |
mvn clean integration-test -Ptest
Loading

0 comments on commit d3bc9ea

Please sign in to comment.