Skip to content

api: deprecate VERSION handle #66

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

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: tarantool/rocks.tarantool.org/github-action@master
with:
auth: ${{ secrets.ROCKS_AUTH }}
Expand All @@ -31,10 +31,10 @@ jobs:
needs: version-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
- uses: actions/checkout@v3
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: '2.8'
tarantool-version: '2.10'

- run: echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
- run: tarantoolctl rocks new_version --tag $TAG
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != 'tarantool'
strategy:
matrix:
tarantool-version: ["1.10", "2.8"]
tarantool-version: ["1.10", "2.10"]
fail-fast: false
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
- uses: actions/checkout@v3
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: ${{ matrix.tarantool-version }}

Expand Down
17 changes: 14 additions & 3 deletions graphql/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
local log = require('log')

local VERSION = require('graphql.version')

return {
VERSION = VERSION,
return setmetatable({
_VERSION = VERSION,
}
}, {
__index = function(_, key)
if key == 'VERSION' then
log.warn("require('graphql').VERSION is deprecated, " ..
"use require('graphql')._VERSION instead.")
return VERSION
end

return nil
end
})
30 changes: 30 additions & 0 deletions test/helpers.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
local clock = require('clock')
local fiber = require('fiber')
local log = require('log')

local types = require('graphql.types')
local schema = require('graphql.schema')
local parse = require('graphql.parse')
Expand Down Expand Up @@ -33,4 +37,30 @@ function helpers.check_request(query, query_schema, mutation_schema, directives,
return execute.execute(compiled_schema, parsed, rootValue, variables)
end

-- Based on https://github.com/tarantool/crud/blob/5717e87e1f8a6fb852c26181524fafdbc7a472d8/test/helper.lua#L533-L544
function helpers.fflush_main_server_output(server, capture)
-- Sometimes we have a delay here. This hack helps to wait for the end of
-- the output. It shouldn't take much time.
local helper_msg = "metrics fflush message"
if server then
server.net_box:eval([[
require('log').error(...)
]], {helper_msg})
else
log.error(helper_msg)
end

local max_wait_timeout = 10
local start_time = clock.monotonic()

local captured = ""
while (not string.find(captured, helper_msg, 1, true))
and (clock.monotonic() - start_time < max_wait_timeout) do
local captured_part = capture:flush()
captured = captured .. (captured_part.stdout or "") .. (captured_part.stderr or "")
fiber.yield()
end
return captured
end

return helpers
17 changes: 17 additions & 0 deletions test/unit/graphql_test.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local t = require('luatest')
local luatest_capture = require('luatest.capture')
local g = t.group('unit')

local helpers = require('test.helpers')

local parse = require('graphql.parse').parse
local types = require('graphql.types')
local schema = require('graphql.schema')
Expand Down Expand Up @@ -1093,6 +1096,20 @@ g.test_version = function()
t.assert_type(require('graphql')._VERSION, 'string')
end

g.test_deprecated_version = function()
local capture = luatest_capture:new()
capture:enable()

t.assert_type(require('graphql').VERSION, 'string')
local stdout = helpers.fflush_main_server_output(nil, capture)
capture:disable()

t.assert_str_contains(
stdout,
"require('graphql').VERSION is deprecated, " ..
"use require('graphql')._VERSION instead.")
end

function g.test_is_array()
t.assert_equals(util.is_array({[3] = 'a', [1] = 'b', [6] = 'c'}), true)
t.assert_equals(util.is_array({[3] = 'a', [1] = 'b', [7] = 'c'}), true)
Expand Down