From ea0c4ea6c54bf5be783e6ae920b65c7290fc5c5a Mon Sep 17 00:00:00 2001 From: FranGuam Date: Mon, 13 Nov 2023 20:15:31 +0800 Subject: [PATCH 1/6] Update dependency --- package.json | 2 +- yarn.lock | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 4cd4747..5dd7830 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "eesast-hasura", "dependencies": { - "hasura-cli": "2.24.1" + "hasura-cli": "2.35.0" }, "scripts": { "apply": "hasura migrate apply && hasura metadata apply", diff --git a/yarn.lock b/yarn.lock index 356bb8a..47eb068 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4,22 +4,22 @@ ansi-styles@^3.2.1: version "3.2.1" - resolved "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" - integrity sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0= + resolved "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== dependencies: color-convert "^1.9.0" axios@^0.21.1: version "0.21.4" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + resolved "https://registry.npmmirror.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== dependencies: follow-redirects "^1.14.0" chalk@^2.4.2: version "2.4.2" - resolved "https://registry.npm.taobao.org/chalk/download/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" - integrity sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ= + resolved "https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== dependencies: ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" @@ -27,42 +27,42 @@ chalk@^2.4.2: color-convert@^1.9.0: version "1.9.3" - resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" - integrity sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg= + resolved "https://registry.npmmirror.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== dependencies: color-name "1.1.3" color-name@1.1.3: version "1.1.3" - resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + resolved "https://registry.npmmirror.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== escape-string-regexp@^1.0.5: version "1.0.5" - resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz?cache=0&sync_timestamp=1587627107924&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fescape-string-regexp%2Fdownload%2Fescape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + resolved "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== follow-redirects@^1.14.0: - version "1.15.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5" - integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== + version "1.15.3" + resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" + integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== has-flag@^3.0.0: version "3.0.0" - resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + resolved "https://registry.npmmirror.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== -hasura-cli@2.24.1: - version "2.24.1" - resolved "https://registry.yarnpkg.com/hasura-cli/-/hasura-cli-2.24.1.tgz#832fe34246a5fe85bde510888c8babc304f7d608" - integrity sha512-qLfjLisf/pe/1/ZVfjcAzndUg5ZKRgXU7eVRiXRVE74YxJFej43ebRsLtBuzJSpAE0Hg7TYw9DaCAjPaBahgQA== +hasura-cli@2.35.0: + version "2.35.0" + resolved "https://registry.npmmirror.com/hasura-cli/-/hasura-cli-2.35.0.tgz#d95dae977fe8d290a63cfe24a576105065c4504c" + integrity sha512-aK3+vR0q2UwUZVai/ojDSQolt7JWI6cxPo8t/Sx4oD4INYgX8u0WRw6W7DWvaPfnSm9yHGEFvfJJnp670Tc3rQ== dependencies: axios "^0.21.1" chalk "^2.4.2" supports-color@^5.3.0: version "5.5.0" - resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz?cache=0&sync_timestamp=1598611732186&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha1-4uaaRKyHcveKHsCzW2id9lMO/I8= + resolved "https://registry.npmmirror.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== dependencies: has-flag "^3.0.0" From 4755fec029a652f89dd7f9e9aa6af8b846a30762 Mon Sep 17 00:00:00 2001 From: FranGuam Date: Mon, 13 Nov 2023 20:21:20 +0800 Subject: [PATCH 2/6] Update Github CI --- .github/renovate.json | 10 +++++++++ .github/workflows/{deploy.yml => actions.yml} | 22 ++++++++++--------- renovate.json | 5 ----- 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 .github/renovate.json rename .github/workflows/{deploy.yml => actions.yml} (62%) delete mode 100644 renovate.json diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..bab3617 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,10 @@ +{ + "extends": ["config:base"], + "automerge": true, + "timezone": "Asia/Shanghai", + "schedule": "after 4am and before 8am every saturday", + "lockFileMaintenance": { + "enabled": true, + "schedule": "after 4pm on saturday" + } +} diff --git a/.github/workflows/deploy.yml b/.github/workflows/actions.yml similarity index 62% rename from .github/workflows/deploy.yml rename to .github/workflows/actions.yml index 9fb5e36..ba513ce 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/actions.yml @@ -1,4 +1,4 @@ -name: deploy +name: actions on: push: @@ -9,18 +9,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 - - name: Use Node.js ${{matrix.node-version}} - uses: actions/setup-node@v3 + - name: Set up Node.js + uses: actions/setup-node@v4 with: - node-version: "14.x" + node-version: "20.x" - - name: get yarn cache path + - name: Get yarn cache path id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - name: Restore yarn cache + uses: actions/cache@v3 id: yarn-cache with: path: ${{steps.yarn-cache-dir-path.outputs.dir}} @@ -28,10 +30,10 @@ jobs: restore-keys: | ${{runner.os}}-yarn- - - name: install dependencies + - name: Install dependencies run: yarn - - name: apply + - name: Apply changes run: | yarn hasura migrate apply --endpoint ${{secrets.HASURA_GRAPHQL_ENDPOINT}} --admin-secret ${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}} yarn hasura metadata apply --endpoint ${{secrets.HASURA_GRAPHQL_ENDPOINT}} --admin-secret ${{secrets.HASURA_GRAPHQL_ADMIN_SECRET}} diff --git a/renovate.json b/renovate.json deleted file mode 100644 index f45d8f1..0000000 --- a/renovate.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "config:base" - ] -} From 0da2fd7da53b8355edc3929979700a9bd9ad6d57 Mon Sep 17 00:00:00 2001 From: FranGuam Date: Mon, 13 Nov 2023 23:28:32 +0800 Subject: [PATCH 3/6] Add share_course table --- metadata/tables.yaml | 17 +++++++++++++++++ .../down.sql | 1 + .../up.sql | 2 ++ .../down.sql | 1 + .../up.sql | 1 + 5 files changed, 22 insertions(+) create mode 100644 migrations/1699879499725_create_table_public_share_course/down.sql create mode 100644 migrations/1699879499725_create_table_public_share_course/up.sql create mode 100644 migrations/1699879664534_alter_table_public_share_course_alter_column_index/down.sql create mode 100644 migrations/1699879664534_alter_table_public_share_course_alter_column_index/up.sql diff --git a/metadata/tables.yaml b/metadata/tables.yaml index e9ebdeb..8430955 100644 --- a/metadata/tables.yaml +++ b/metadata/tables.yaml @@ -3192,6 +3192,23 @@ - salutation - type filter: {} +- table: + name: share_course + schema: public + select_permissions: + - role: student + permission: + columns: + - year + - code + - fullname + - language + - name + - professor + - semester + - type + - uuid + filter: {} - table: name: tag schema: public diff --git a/migrations/1699879499725_create_table_public_share_course/down.sql b/migrations/1699879499725_create_table_public_share_course/down.sql new file mode 100644 index 0000000..40064eb --- /dev/null +++ b/migrations/1699879499725_create_table_public_share_course/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."share_course"; diff --git a/migrations/1699879499725_create_table_public_share_course/up.sql b/migrations/1699879499725_create_table_public_share_course/up.sql new file mode 100644 index 0000000..8f039e0 --- /dev/null +++ b/migrations/1699879499725_create_table_public_share_course/up.sql @@ -0,0 +1,2 @@ +CREATE TABLE "public"."share_course" ("uuid" uuid NOT NULL DEFAULT gen_random_uuid(), "index" text NOT NULL, "fullname" text NOT NULL, "name" text NOT NULL, "year" integer NOT NULL DEFAULT 2000, "semester" text NOT NULL, "professor" text NOT NULL, "type" Text NOT NULL, "language" text NOT NULL DEFAULT '中文', PRIMARY KEY ("uuid") , UNIQUE ("uuid"));COMMENT ON TABLE "public"."share_course" IS E'所有电子系的课程,用于课程评测'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/migrations/1699879664534_alter_table_public_share_course_alter_column_index/down.sql b/migrations/1699879664534_alter_table_public_share_course_alter_column_index/down.sql new file mode 100644 index 0000000..c0bcf3f --- /dev/null +++ b/migrations/1699879664534_alter_table_public_share_course_alter_column_index/down.sql @@ -0,0 +1 @@ +alter table "public"."share_course" rename column "code" to "index"; diff --git a/migrations/1699879664534_alter_table_public_share_course_alter_column_index/up.sql b/migrations/1699879664534_alter_table_public_share_course_alter_column_index/up.sql new file mode 100644 index 0000000..6db597f --- /dev/null +++ b/migrations/1699879664534_alter_table_public_share_course_alter_column_index/up.sql @@ -0,0 +1 @@ +alter table "public"."share_course" rename column "index" to "code"; From c47265a2c91105c6fd279f3cc7f6bbf94a70af6e Mon Sep 17 00:00:00 2001 From: FranGuam Date: Tue, 14 Nov 2023 01:31:28 +0800 Subject: [PATCH 4/6] Update Github CI --- .github/mergify.yml | 35 ++++++++++++++++++++++++++ .github/workflows/actions.yml | 46 ++++++++++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 .github/mergify.yml diff --git a/.github/mergify.yml b/.github/mergify.yml new file mode 100644 index 0000000..efb035e --- /dev/null +++ b/.github/mergify.yml @@ -0,0 +1,35 @@ +pull_request_rules: + - name: branch name check + conditions: + - "head~=^(master|main)/" + - "-merged" + - "-closed" + actions: + close: + message: | + @{{author}} + Wrong Branch Name: {{head}} + Please use a meaningful name instead. + This Pull Request will be closed. + label: + add: + - "invalid" + - name: delete head branch after merge + conditions: + - merged + actions: + delete_head_branch: {} + - name: automatic label Renovate pull requests + conditions: + - author=renovate[bot] + actions: + label: + add: + - "dependencies" + - name: automatic merge for Renovate pull requests + conditions: + - author=renovate[bot] + - check-success=test + actions: + merge: + method: rebase diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index ba513ce..0d64a48 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,11 +1,51 @@ name: actions -on: - push: - branches: [master] +on: [push, pull_request] jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Test Run + shell: bash + run: docker compose up -d + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - name: Get yarn cache path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{steps.yarn-cache-dir-path.outputs.dir}} + key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}} + restore-keys: | + ${{runner.os}}-yarn- + + - name: Install dependencies + run: yarn + + - name: Test Apply changes + run: | + yarn hasura migrate apply --endpoint http://localhost:23333 + yarn hasura metadata apply --endpoint http://localhost:23333 + deploy: + if: | + github.event_name == 'push' && + github.ref_name == 'master' && + github.repository_owner == 'eesast' + needs: test runs-on: ubuntu-latest steps: From 03427434aad6901dd3c41b5c3cb2ec114f2d1cb5 Mon Sep 17 00:00:00 2001 From: FranGuam Date: Tue, 14 Nov 2023 01:45:24 +0800 Subject: [PATCH 5/6] fix --- docker-compose.yaml => docker-compose.yml | 1 + 1 file changed, 1 insertion(+) rename docker-compose.yaml => docker-compose.yml (96%) diff --git a/docker-compose.yaml b/docker-compose.yml similarity index 96% rename from docker-compose.yaml rename to docker-compose.yml index d40c092..efc32df 100644 --- a/docker-compose.yaml +++ b/docker-compose.yml @@ -31,3 +31,4 @@ services: HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log ## uncomment next line to set an admin secret # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey + ACTION_SECRET: myactionsecretkey From be8af897e43d5a59be22f3719a15be3615c4c418 Mon Sep 17 00:00:00 2001 From: FranGuam Date: Tue, 14 Nov 2023 01:48:50 +0800 Subject: [PATCH 6/6] lint --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 0d64a48..5e52cc5 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -35,7 +35,7 @@ jobs: - name: Install dependencies run: yarn - - name: Test Apply changes + - name: Test apply run: | yarn hasura migrate apply --endpoint http://localhost:23333 yarn hasura metadata apply --endpoint http://localhost:23333