Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add CI validation for pull requests #217

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
be51b2c
chore: add ci for pr
jonas-jonas Oct 21, 2022
5c136a2
u
jonas-jonas Oct 23, 2022
36605af
u
jonas-jonas Oct 23, 2022
b08c69c
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Dec 7, 2022
55c3412
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Dec 9, 2022
571327e
chore: add matrix CI runs
jonas-jonas Dec 9, 2022
5b78c0e
chore: generate all clients in single workflow
jonas-jonas Dec 12, 2022
da0fe3b
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Jan 30, 2023
8a32fec
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Feb 7, 2023
ebadd3b
chore: update network version
jonas-jonas Feb 7, 2023
f0be852
chore: u
jonas-jonas Feb 7, 2023
4ec4d1f
chore: u
jonas-jonas Feb 7, 2023
55061e3
chore: u
jonas-jonas Feb 7, 2023
6696901
chore: enable all languages
jonas-jonas Feb 7, 2023
f13d209
chore: u
jonas-jonas Feb 7, 2023
bc6e343
u
jonas-jonas Feb 10, 2023
3a1a671
u
jonas-jonas Feb 10, 2023
3cd632a
u
jonas-jonas Feb 10, 2023
647e0af
u
jonas-jonas Feb 10, 2023
4c7190c
u
jonas-jonas Feb 10, 2023
c765aa9
y
jonas-jonas Feb 10, 2023
2ed61b4
u
jonas-jonas Feb 10, 2023
cba5251
chore: cleanup
jonas-jonas Feb 10, 2023
86f6051
chore: fix baseDir
jonas-jonas Feb 10, 2023
33ef6d3
chore: fix dat call
jonas-jonas Feb 13, 2023
460b569
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Apr 26, 2023
c7b851d
chore: use latest SDK image
jonas-jonas Apr 26, 2023
524b591
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Apr 29, 2023
085fb22
Merge remote-tracking branch 'origin/master' into feat/ciOnPR
jonas-jonas Jun 28, 2024
1133c94
chore: ruby
jonas-jonas Jun 28, 2024
2edddad
chore: remove oryd/sdk from ruby build
jonas-jonas Jun 28, 2024
6c9702e
chore: checkout
jonas-jonas Jun 28, 2024
a6b86d3
chore: u
jonas-jonas Jun 28, 2024
53009f6
chore: u
jonas-jonas Jun 28, 2024
7894b87
u
jonas-jonas Jun 28, 2024
082d94b
u
jonas-jonas Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/sdk-build-and-test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "sdk-build-and-test"
description: "Generate & test SDK for a project"
inputs:
language:
required: true
description: The target language of the SDK
version:
required: false
default: "latest"
description: The target version of the SDK
project:
required: true
description: The target project of the SDK. Can be one of client, keto, kratos, oathkeeper or hydra.

runs:
using: composite
steps:
- name: "gen: ${{ inputs.language }}"
run: ./scripts/generate.sh ${{ inputs.language }} ${{ inputs.version }} ${{ inputs.project }}
- name: "test: ${{ inputs.language }}"
run: ./scripts/test.sh ${{ inputs.language }} ${{ inputs.version }} ${{ inputs.project }}
24 changes: 24 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI
on:
# push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
container: oryd/sdk:v0.0.50
strategy:
matrix:
language: ["golang", "typescript"] # TODO: add the other languages
steps:
- uses: actions/checkout@v3
- name: "client"
run: ./scripts/generate-and-test.sh ${{ matrix.language }} latest client
- name: "keto"
run: ./scripts/generate-and-test.sh ${{ matrix.language }} latest keto
- name: "kratos"
run: ./scripts/generate-and-test.sh ${{ matrix.language }} latest kratos
- name: "hydra"
run: ./scripts/generate-and-test.sh ${{ matrix.language }} latest hydra
- name: "oathkeeper"
run: ./scripts/generate-and-test.sh ${{ matrix.language }} latest oathkeeper
7 changes: 7 additions & 0 deletions scripts/generate-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Mainly used by the CI tasks

# Both use the same arguments
./scripts/generate.sh $1 $2 $3
./scripts/test.sh $1 $2 $3
142 changes: 94 additions & 48 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

set -Eeuxo pipefail

cd "$( dirname "${BASH_SOURCE[0]}" )/.."
init() {
cd "$(dirname "${BASH_SOURCE[0]}")/.."

source scripts/prep.sh
source scripts/prep.sh

rm -rf config/client/*.proc.yml
rm -rf config/client/*.proc.yml

for f in config/client/*
do
echo "Processing $f..."
envsubst < "${f}" > "${f}.proc.yml"
done
for f in config/client/*; do
echo "Processing $f..."
envsubst <"${f}" >"${f}.proc.yml"
done
}

cleanup() {
rm "clients/${PROJECT}/java/git_push.sh" || true
Expand All @@ -34,7 +35,7 @@ cleanup() {
rm "clients/${PROJECT}/rust/.travis.yml" || true
}

typescript () {
typescript() {
echo "Generating TypeScript..."

dir="clients/${PROJECT}/typescript"
Expand All @@ -52,13 +53,13 @@ typescript () {

file="${dir}/package.json"
jq -r ".author = "'"'"ORY GmbH"'"'" | .license = "'"'"Apache-2.0"'"' "${file}" \
> tmp.$$.json && mv tmp.$$.json "${file}"
>tmp.$$.json && mv tmp.$$.json "${file}"

cat "${file}"
cp "LICENSE" "clients/${PROJECT}/typescript"
}

java () {
java() {
echo "Generating Java..."

dir="clients/${PROJECT}/java"
Expand Down Expand Up @@ -145,13 +146,13 @@ php() {
file="${dir}/composer.json"

jq -r ".name=\"${PHP_PACKAGE_NAME}-php\" | .homepage = \"https://github.com/ory/${GIT_REPO}-php\" | .authors[0].name = \"Ory GmbH\" | .authors[0].homepage = \"https://www.ory.sh\" | .license = \"Apache-2.0\"" "${file}" \
> tmp.$$.json && mv tmp.$$.json "${file}"
>tmp.$$.json && mv tmp.$$.json "${file}"

cat "${file}"
cp "LICENSE" "clients/${PROJECT}/php"
}

python () {
python() {
echo "Generating Python..."

dir="clients/${PROJECT}/python"
Expand All @@ -169,7 +170,7 @@ python () {
cp "LICENSE" "clients/${PROJECT}/python"
}

ruby () {
ruby() {
echo "Generating Ruby..."

dir="clients/${PROJECT}/ruby"
Expand All @@ -189,15 +190,18 @@ ruby () {

file="${dir}/lib/${RUBY_PROJECT_NAME}/version.rb"

(sed "s/${VERSION}/${GEM_VERSION}/g" < "${file}") > tmp.$$.rb && mv tmp.$$.rb "${file}"
(sed "s/${VERSION}/${GEM_VERSION}/g" <"${file}") >tmp.$$.rb && mv tmp.$$.rb "${file}"

(cd ${dir}; sed "/^end.*/i \ gem 'psych', '~> 4.0.6'" < Gemfile) > tmp.$$.Gemfile && mv tmp.$$.Gemfile "${dir}/Gemfile"
(
cd ${dir}
sed "/^end.*/i \ gem 'psych', '~> 4.0.6'" <Gemfile
) >tmp.$$.Gemfile && mv tmp.$$.Gemfile "${dir}/Gemfile"

cat "${file}"
cp "LICENSE" "clients/${PROJECT}/ruby"
}

golang () {
golang() {
echo "Generating Golang..."

dir="clients/${PROJECT}/go"
Expand All @@ -215,17 +219,32 @@ golang () {
--git-host github.com \
-c ./config/client/go.yml.proc.yml
cp "LICENSE" "clients/${PROJECT}/go"

if [ "${PROJECT}" == "hydra" ]; then
(cd "${dir}"; rm go.mod go.sum || true; go mod init "github.com/ory/${PROJECT}-client-go/v2"; go mod tidy)
(
cd "${dir}"
rm go.mod go.sum || true
go mod init "github.com/ory/${PROJECT}-client-go/v2"
go mod tidy
)
elif [ "${PROJECT}" == "client" ]; then
(cd "${dir}"; rm go.mod go.sum || true; go mod init "github.com/ory/client-go"; go mod tidy)
(
cd "${dir}"
rm go.mod go.sum || true
go mod init "github.com/ory/client-go"
go mod tidy
)
else
(cd "${dir}"; rm go.mod go.sum || true; go mod init "github.com/ory/${PROJECT}-client-go"; go mod tidy)
(
cd "${dir}"
rm go.mod go.sum || true
go mod init "github.com/ory/${PROJECT}-client-go"
go mod tidy
)
fi
}

dotnet () {
dotnet() {
echo "Generating dotnet..."

dir="clients/${PROJECT}/dotnet"
Expand All @@ -244,7 +263,7 @@ dotnet () {
cp "LICENSE" "clients/${PROJECT}/dotnet"
}

dart () {
dart() {
echo "Generating Dart..."

dir="clients/${PROJECT}/dart"
Expand All @@ -263,7 +282,7 @@ dart () {
cp "LICENSE" "clients/${PROJECT}/dart"
}

rust () {
rust() {
echo "Generating Rust..."

dir="clients/${PROJECT}/rust"
Expand All @@ -286,47 +305,74 @@ rust () {
file="${dir}/Cargo.toml"

if [ $project != "client" ]; then
(sed "s/${VERSION}/${RAW_VERSION}"'"\ndescription = "SDK Client for Ory '"${PROJECT_UCF}"'"\ndocumentation = "https:\/\/www.ory.sh\/'"${PROJECT}"'\/docs\/sdk"\nhomepage = "https:\/\/www.ory.sh"\nlicense = "Apache-2.0/g' < "${file}") > tmp.$$.rb && mv tmp.$$.rb "${file}"
(sed "s/${VERSION}/${RAW_VERSION}"'"\ndescription = "SDK Client for Ory '"${PROJECT_UCF}"'"\ndocumentation = "https:\/\/www.ory.sh\/'"${PROJECT}"'\/docs\/sdk"\nhomepage = "https:\/\/www.ory.sh"\nlicense = "Apache-2.0/g' <"${file}") >tmp.$$.rb && mv tmp.$$.rb "${file}"
else
(sed "s/${VERSION}/${RAW_VERSION}"'"\ndescription = "SDK Client for Ory"\ndocumentation = "https:\/\/www.ory.sh\/docs\/sdk"\nhomepage = "https:\/\/www.ory.sh"\nlicense = "Apache-2.0/g' < "${file}") > tmp.$$.rb && mv tmp.$$.rb "${file}"
(sed "s/${VERSION}/${RAW_VERSION}"'"\ndescription = "SDK Client for Ory"\ndocumentation = "https:\/\/www.ory.sh\/docs\/sdk"\nhomepage = "https:\/\/www.ory.sh"\nlicense = "Apache-2.0/g' <"${file}") >tmp.$$.rb && mv tmp.$$.rb "${file}"
fi
cp "LICENSE" "clients/${PROJECT}/rust"
}

elixir () {
elixir() {
echo "Generating Elixir..."

dir="clients/${PROJECT}/elixir"
rm -rf "$dir" || true
mkdir -p "$dir"


file="${dir}/mix.exs"

openapi-generator-cli version-manager set 6.2.1
openapi-generator-cli generate -i "${SPEC_FILE}" \
-g elixir \
-o "$dir" \
--git-user-id ory \
--git-repo-id sdk \
--git-host github.com \
-c ./config/client/elixir.yml.proc.yml
-g elixir \
-o "$dir" \
--git-user-id ory \
--git-repo-id sdk \
--git-host github.com \
-c ./config/client/elixir.yml.proc.yml

(sed "s/licenses:.*$/licenses: [\"Apache-2.0\"],\n links: %{\n \"GitHub\" => \"https:\/\/github.com\/ory\/sdk\",\n \"Website\" => \"https:\/\/www.ory.sh\",\n \"Documentation\" => \"https:\/\/www.ory.sh\/docs\",\n \"Product\" => \"https:\/\/console.ory.sh\"\n }/g" < "${file}") > tmp.$$.exs && mv tmp.$$.exs "${file}"
(sed "s/${VERSION}/${RAW_VERSION}/g" < "${file}") > tmp.$$.exs && mv tmp.$$.exs "${file}"
(sed "s/licenses:.*$/licenses: [\"Apache-2.0\"],\n links: %{\n \"GitHub\" => \"https:\/\/github.com\/ory\/sdk\",\n \"Website\" => \"https:\/\/www.ory.sh\",\n \"Documentation\" => \"https:\/\/www.ory.sh\/docs\",\n \"Product\" => \"https:\/\/console.ory.sh\"\n }/g" <"${file}") >tmp.$$.exs && mv tmp.$$.exs "${file}"
(sed "s/${VERSION}/${RAW_VERSION}/g" <"${file}") >tmp.$$.exs && mv tmp.$$.exs "${file}"

cp "LICENSE" "clients/${PROJECT}/elixir"
}

elixir
typescript
rust
golang
java
php
python
ruby
dotnet
dart

cleanup
generate() {
if [ "$(type -t $1)" = "function" ]; then
# Did we actually get a function ref?
FORCE_VERSION=$2
FORCE_PROJECT=$3
if [ $FORCE_VERSION = "latest" ]; then
# TODO: Make the client parameterized as well
FORCE_VERSION=$(cat spec/$FORCE_PROJECT/latest)
fi

init

$1

cleanup
else
echo "$1 is not a valid generator..."
fi
}

if [ $# -lt 3 ]; then
# if no parameter is given, just execute all generators, as before.
# This is needed by the release pipeline
init

elixir
typescript
rust
golang
java
php
python
ruby
dotnet
dart

cleanup
else
generate $1 $2 $3
fi
Loading