Skip to content

chore: add CI validation for pull requests #217

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

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions .github/actions/generate-and-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
inputs:
language:
description: "The language to use for the generated project"
required: true

runs:
using: "composite"
steps:
# - shell: bash
# run: cp -r /root/. $HOME # Workaround, because $HOME is set to /github/home inside the action run
- name: "client"
shell: bash
run: ./scripts/generate-and-test.sh ${{ inputs.language }} latest client
- name: "keto"
shell: bash
run: ./scripts/generate-and-test.sh ${{ inputs.language }} latest keto
- name: "kratos"
shell: bash
run: ./scripts/generate-and-test.sh ${{ inputs.language }} latest kratos
- name: "hydra"
shell: bash
run: ./scripts/generate-and-test.sh ${{ inputs.language }} latest hydra
- name: "oathkeeper"
shell: bash
run: ./scripts/generate-and-test.sh ${{ inputs.language }} latest oathkeeper
44 changes: 44 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI
on:
pull_request:

jobs:
# test:
# runs-on: ubuntu-latest
# container: oryd/sdk:v0.0.53
# defaults:
# run:
# shell: bash
# strategy:
# matrix:
# language:
# [
# "elixir",
# "typescript",
# "rust",
# "golang",
# "java",
# "php",
# "python",
# "dotnet",
# "dart",
# ]
# steps:
# - uses: actions/checkout@v4
# - name: Generate and Test - ${{ matrix.language }}
# uses: ./.github/actions/generate-and-test
# with:
# language: ${{ matrix.language }}
test-ruby:
runs-on: ubuntu-latest
steps:
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: 2.7
- uses: actions/checkout@v4
- run: ls -la .
- name: Generate and Test
uses: ./.github/actions/generate-and-test
with:
language: ruby
8 changes: 8 additions & 0 deletions scripts/generate-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -Eeuxo pipefail

# Mainly used by the CI tasks

# Both use the same arguments
./scripts/generate.sh $1 $2 $3
./scripts/test.sh $1 $2 $3
116 changes: 71 additions & 45 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 Down Expand Up @@ -175,7 +176,7 @@ php() {
cp "LICENSE" "clients/${PROJECT}/php"
}

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

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

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

dir="clients/${PROJECT}/ruby"
Expand All @@ -213,15 +214,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 Down Expand Up @@ -249,7 +253,7 @@ golang () {
fi
}

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

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

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

dir="clients/${PROJECT}/dart"
Expand All @@ -290,7 +294,7 @@ dart () {
(cd $dir; command dart run build_runner build)
}

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

dir="clients/${PROJECT}/rust"
Expand All @@ -312,52 +316,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"

# 7.4.0
openapi-generator-cli version-manager set 7.4.0
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 is broken right now: https://github.com/ory/sdk/issues/350
#elixir
typescript
typescript_fetch
rust
golang
java
php
python

# ruby is broken right now: https://github.com/ory/sdk/issues/357
# 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
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
Loading