From 36781804b359235fb5ec40d13e7c414b6bb7068f Mon Sep 17 00:00:00 2001 From: Rukmal Weerawarana Date: Tue, 27 Sep 2022 22:40:30 +0530 Subject: [PATCH] Add workflow to publish graphql client to central on release - Add functionality to automatically update version numbers - Fix bug in db that was breaking idempotent deployment. Filed #18 --- .github/workflows/push.yml | 2 +- .github/workflows/release.yml | 55 +++++ api/.gitignore | 1 + api/Dependencies.toml | 381 ---------------------------------- client/.gitignore | 1 + client/Dependencies.toml | 328 ----------------------------- db/schema/3-avinya_types.sql | 4 +- db/schema/4-person.sql | 13 ++ 8 files changed, 73 insertions(+), 712 deletions(-) delete mode 100644 api/Dependencies.toml delete mode 100644 client/Dependencies.toml create mode 100644 db/schema/4-person.sql diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ae79d4e..3bb7e39 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -85,7 +85,7 @@ jobs: args: test env: WORKING_DIR: api - generate-graphql-client-job: + generate-graphql-client: name: Generate GraphQL Client needs: api-test runs-on: ubuntu-22.04 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7ce668..417e9d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,42 @@ on: - "published" jobs: + update-version: + runs-on: ubuntu-22.04 + name: Update package version numbers + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Extract version number from tag + id: vars + # See: https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + - name: Test output vars + env: + RELEASE_VERSION: ${{ steps.meta.vars.outputs.tag }} + run: echo $RELEASE_VERSION + # - name: Update API version in package files + # uses: ciiiii/toml-editor@1.0.0 + # with: + # file: api/Ballerina.toml + # key: "package.version" + # value: ${{ steps.vars.outputs.tag }} + # - name: Update client version in package files + # uses: ciiiii/toml-editor@1.0.0 + # with: + # file: client/Ballerina.toml + # key: "package.version" + # value: ${{ steps.vars.outputs.tag }} + # - name: Commit version changes to repository + # uses: EndBug/add-and-commit@v9 # See: https://github.com/marketplace/actions/add-commit + # with: + # add: "." + # push: origin main + # default_author: github_actions + # message: "[GitHub Actions] Commit version updates" update-staging-db: name: Update Azure staging database + needs: update-version runs-on: ubuntu-22.04 environment: Staging permissions: @@ -26,3 +60,24 @@ jobs: USER: ${{ secrets.DB_USER }} PASSWORD: ${{ secrets.DB_PASSWORD }} DATABASE: ${{ secrets.DB_DATABASE }} + push-api-client: + name: Publish GraphQL API Client + needs: update-staging-db + runs-on: ubuntu-22.04 + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Build distribution archive of client package + uses: ballerina-platform/ballerina-action@394eb82cc07e020948fee8d1474143ae393147f4 + with: + args: pack + env: + WORKING_DIR: client + - name: Push to central + uses: ballerina-platform/ballerina-action@394eb82cc07e020948fee8d1474143ae393147f4 + with: + args: push + env: + WORKING_DIR: client diff --git a/api/.gitignore b/api/.gitignore index eb5a316..5cf2b2a 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -1 +1,2 @@ target +Dependencies.toml diff --git a/api/Dependencies.toml b/api/Dependencies.toml deleted file mode 100644 index 966943f..0000000 --- a/api/Dependencies.toml +++ /dev/null @@ -1,381 +0,0 @@ -# AUTO-GENERATED FILE. DO NOT MODIFY. - -# This file is auto-generated by Ballerina for managing dependency versions. -# It should not be modified by hand. - -[ballerina] -dependencies-toml-version = "2" - -[[package]] -org = "avinyafoundation" -name = "global_data_api" -version = "1.0.0" -dependencies = [ - {org = "ballerina", name = "graphql"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "sql"}, - {org = "ballerina", name = "test"}, - {org = "ballerinai", name = "observe"}, - {org = "ballerinax", name = "mysql"}, - {org = "ballerinax", name = "mysql.driver"} -] -modules = [ - {org = "avinyafoundation", packageName = "global_data_api", moduleName = "global_data_api"} -] - -[[package]] -org = "ballerina" -name = "auth" -version = "2.3.1" -dependencies = [ - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "regex"} -] - -[[package]] -org = "ballerina" -name = "cache" -version = "3.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "task"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "crypto" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "file" -version = "1.3.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "os"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "graphql" -version = "1.3.3" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "file"}, - {org = "ballerina", name = "http"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "mime"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "websocket"} -] -modules = [ - {org = "ballerina", packageName = "graphql", moduleName = "graphql"}, - {org = "ballerina", packageName = "graphql", moduleName = "graphql.parser"} -] - -[[package]] -org = "ballerina" -name = "http" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "file"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.decimal"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "lang.runtime"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "mime"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "observe"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"}, - {org = "ballerina", name = "url"} -] - -[[package]] -org = "ballerina" -name = "io" -version = "1.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.value"} -] -modules = [ - {org = "ballerina", packageName = "io", moduleName = "io"} -] - -[[package]] -org = "ballerina" -name = "jballerina.java" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "jwt" -version = "2.3.1" -dependencies = [ - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "lang.__internal" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.object"} -] - -[[package]] -org = "ballerina" -name = "lang.array" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.__internal"} -] - -[[package]] -org = "ballerina" -name = "lang.decimal" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.int" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.object" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "lang.runtime" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.string" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.value" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "log" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "observe"} -] - -[[package]] -org = "ballerina" -name = "mime" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"} -] - -[[package]] -org = "ballerina" -name = "oauth2" -version = "2.3.1" -dependencies = [ - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "observe" -version = "1.0.5" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "os" -version = "1.3.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "regex" -version = "1.3.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.string"} -] - -[[package]] -org = "ballerina" -name = "sql" -version = "1.4.1" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.object"}, - {org = "ballerina", name = "time"} -] -modules = [ - {org = "ballerina", packageName = "sql", moduleName = "sql"} -] - -[[package]] -org = "ballerina" -name = "task" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "test" -version = "0.0.0" -scope = "testOnly" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] -modules = [ - {org = "ballerina", packageName = "test", moduleName = "test"} -] - -[[package]] -org = "ballerina" -name = "time" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "url" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "websocket" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "http"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.runtime"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerinai" -name = "observe" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "observe"} -] -modules = [ - {org = "ballerinai", packageName = "observe", moduleName = "observe"} -] - -[[package]] -org = "ballerinax" -name = "mysql" -version = "1.4.1" -dependencies = [ - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "sql"}, - {org = "ballerina", name = "time"} -] -modules = [ - {org = "ballerinax", packageName = "mysql", moduleName = "mysql"} -] - -[[package]] -org = "ballerinax" -name = "mysql.driver" -version = "1.3.0" -modules = [ - {org = "ballerinax", packageName = "mysql.driver", moduleName = "mysql.driver"} -] - - diff --git a/client/.gitignore b/client/.gitignore index eb5a316..5cf2b2a 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -1 +1,2 @@ target +Dependencies.toml diff --git a/client/Dependencies.toml b/client/Dependencies.toml deleted file mode 100644 index 3d0ca35..0000000 --- a/client/Dependencies.toml +++ /dev/null @@ -1,328 +0,0 @@ -# AUTO-GENERATED FILE. DO NOT MODIFY. - -# This file is auto-generated by Ballerina for managing dependency versions. -# It should not be modified by hand. - -[ballerina] -dependencies-toml-version = "2" - -[[package]] -org = "avinyafoundation" -name = "global_data_client" -version = "0.1.2" -dependencies = [ - {org = "ballerina", name = "graphql"}, - {org = "ballerina", name = "http"}, - {org = "ballerinai", name = "observe"} -] -modules = [ - {org = "avinyafoundation", packageName = "global_data_client", moduleName = "global_data_client"} -] - -[[package]] -org = "ballerina" -name = "auth" -version = "2.3.1" -dependencies = [ - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "regex"} -] - -[[package]] -org = "ballerina" -name = "cache" -version = "3.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "task"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "crypto" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "file" -version = "1.3.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "os"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "graphql" -version = "1.3.3" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "file"}, - {org = "ballerina", name = "http"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "mime"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "websocket"} -] -modules = [ - {org = "ballerina", packageName = "graphql", moduleName = "graphql"}, - {org = "ballerina", packageName = "graphql", moduleName = "graphql.parser"} -] - -[[package]] -org = "ballerina" -name = "http" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "file"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.decimal"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "lang.runtime"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "mime"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "observe"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"}, - {org = "ballerina", name = "url"} -] -modules = [ - {org = "ballerina", packageName = "http", moduleName = "http"} -] - -[[package]] -org = "ballerina" -name = "io" -version = "1.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.value"} -] - -[[package]] -org = "ballerina" -name = "jballerina.java" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "jwt" -version = "2.3.1" -dependencies = [ - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "lang.__internal" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.object"} -] - -[[package]] -org = "ballerina" -name = "lang.array" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.__internal"} -] - -[[package]] -org = "ballerina" -name = "lang.decimal" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.int" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.object" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "lang.runtime" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.string" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "lang.value" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "log" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "observe"} -] - -[[package]] -org = "ballerina" -name = "mime" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.int"} -] - -[[package]] -org = "ballerina" -name = "oauth2" -version = "2.3.1" -dependencies = [ - {org = "ballerina", name = "cache"}, - {org = "ballerina", name = "crypto"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "observe" -version = "1.0.5" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "os" -version = "1.3.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "regex" -version = "1.3.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "lang.string"} -] - -[[package]] -org = "ballerina" -name = "task" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerina" -name = "time" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "url" -version = "2.2.2" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] - -[[package]] -org = "ballerina" -name = "websocket" -version = "2.3.0" -dependencies = [ - {org = "ballerina", name = "auth"}, - {org = "ballerina", name = "http"}, - {org = "ballerina", name = "io"}, - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "jwt"}, - {org = "ballerina", name = "lang.array"}, - {org = "ballerina", name = "lang.runtime"}, - {org = "ballerina", name = "lang.string"}, - {org = "ballerina", name = "lang.value"}, - {org = "ballerina", name = "log"}, - {org = "ballerina", name = "oauth2"}, - {org = "ballerina", name = "regex"}, - {org = "ballerina", name = "time"} -] - -[[package]] -org = "ballerinai" -name = "observe" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "observe"} -] -modules = [ - {org = "ballerinai", packageName = "observe", moduleName = "observe"} -] - - diff --git a/db/schema/3-avinya_types.sql b/db/schema/3-avinya_types.sql index 4bf03ca..58be1dd 100644 --- a/db/schema/3-avinya_types.sql +++ b/db/schema/3-avinya_types.sql @@ -22,6 +22,6 @@ CREATE TABLE IF NOT EXISTS avinya_type ( ); ALTER TABLE organization -ADD COLUMN avinya_type INT NOT NULL; +ADD COLUMN organization.avinya_type INT NOT NULL; ALTER TABLE organization -ADD FOREIGN KEY (avinya_type) REFERENCES avinya_db.avinya_type(id); +ADD FOREIGN KEY (organization.avinya_type) REFERENCES avinya_db.avinya_type(id); diff --git a/db/schema/4-person.sql b/db/schema/4-person.sql new file mode 100644 index 0000000..0708405 --- /dev/null +++ b/db/schema/4-person.sql @@ -0,0 +1,13 @@ +-- USE avinya_db; + +-- -- Person +-- CREATE TABLE IF NOT EXISTS person ( +-- asgardeo_id VARCHAR(255) NOT NULL PRIMARY KEY, +-- permanent_address INT NOT NULL, +-- mailing_address INT NOT NULL, +-- phone INT, +-- organization INT, +-- FOREIGN KEY (permanent_address) REFERENCES address(id), +-- FOREIGN KEY (mailing_address) REFERENCES address(id), +-- FOREIGN KEY (organization) REFERENCES organization(id), +-- );