diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8c098ba --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +# This is a basic workflow to help you get started with Actions + +name: test + +# Controls when the action will run. +on: push +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + strategy: + matrix: + neovim: [false, true] + version: ['nightly', 'stable'] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + use_gh_cli: [false, true] + runs-on: '${{ matrix.os }}' + steps: + - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + repository: thinca/vim-themis + path: vim-themis + - name: Setup vim + id: vim + uses: rhysd/action-setup-vim@v1 + with: + neovim: ${{ matrix.neovim }} + version: ${{ matrix.version }} + - name: Write gh cli config file for test and check path + if: ${{ matrix.use_gh_cli }} + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + import os + import subprocess + from os.path import expanduser + + process = subprocess.Popen(["gh", "auth", "login", "--with-token"], stdin=subprocess.PIPE) + process.communicate(input=os.environ["TOKEN"].encode()) + retcode = process.poll() + if retcode: + exit(1) + + home = expanduser("~") + with open(os.path.join(home, ".config", "gh", "hosts.yml")) as cfg: + assert cfg.read() + shell: python + - name: Run unit tests with themis.vim + env: + THEMIS_VIM: ${{ steps.vim.outputs.executable }} + USE_GH_CLI: ${{ matrix.use_gh_cli }} + run: ./vim-themis/bin/themis -r diff --git a/test/gh/gh.vim b/test/gh/gh.vim new file mode 100644 index 0000000..9840d05 --- /dev/null +++ b/test/gh/gh.vim @@ -0,0 +1,17 @@ +let s:suite = themis#suite('gh') +let s:assert = themis#helper('assert') + +function! s:suite.test_get_gh_token() + let gh_token = gh#gh#get_token() + if 'true' ==# $USE_GH_CLI + call s:assert.false(empty(gh_token)) + else + call s:assert.true(empty(gh_token)) + endif +endfunction + +function! s:suite.overwrite_gh_token() + let g:gh_token = 'xxx' + let token = gh#gh#get_token() + call s:assert.equals(token, g:gh_token) +endfunction