Skip to content

Commit

Permalink
Add GitHub Actions CI workflow and remove Travis config
Browse files Browse the repository at this point in the history
  • Loading branch information
dstillman committed Jan 30, 2021
1 parent d594dcf commit 1c807c6
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .ci/checkDeletedTxt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "$SCRIPT_DIR/helper.sh"
cd "$SCRIPT_DIR"

MASTER="master"
MASTER="origin/master"
BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ "$BRANCH" = "$MASTER" ]];then
echo "${color_warn}skip${color_reset} - Can only check deleted.txt when not on '$MASTER' branch"
exit 0
fi

if ! git branch |grep -q "$MASTER"; then
if ! git branch -a | grep -q "$MASTER"; then
echo "${color_warn}skip${color_reset} - Can only check deleted.txt when '$MASTER' branch is also available for comparison"
exit 0
fi
Expand Down
2 changes: 1 addition & 1 deletion .ci/eslint-plugin-zotero-translator/lib/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Cache {
.map(line => line.trim())
.includes('upstream\thttps://github.com/zotero/translators.git');
// branch to compare lastUpdated against -- assume that if have upstream/master, you want to compare against that
const master = hasUpstream ? 'upstream/master' : 'master';
const master = hasUpstream ? 'upstream/master' : 'origin/master';

this.lastUpdated = {};
if (branch !== master) {
Expand Down
4 changes: 2 additions & 2 deletions .ci/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ get_translators_to_check() {
# Size of $parent_commits array
local num_parent_commits=${#parent_commits[@]}
if [ $num_parent_commits -gt 1 ]; then
TRANSLATORS_TO_CHECK=$(git diff HEAD^2 $(git rev-list "$(git rev-list --first-parent ^master HEAD^2 | tail -n1)^^!") --name-only | grep -e "^[^/]*.js$")
TRANSLATORS_TO_CHECK=$(git diff HEAD^2 $(git rev-list "$(git rev-list --first-parent ^origin/master HEAD^2 | tail -n1)^^!") --name-only | grep -e "^[^/]*.js$")
else
TRANSLATORS_TO_CHECK=$(git diff $(git rev-list "$(git rev-list --first-parent ^master HEAD | tail -n1)^^!") --name-only | grep -e "^[^/]*.js$")
TRANSLATORS_TO_CHECK=$(git diff $(git rev-list "$(git rev-list --first-parent ^origin/master HEAD | tail -n1)^^!") --name-only | grep -e "^[^/]*.js$")
fi
}
4 changes: 0 additions & 4 deletions .ci/pull-request-check/check-pull-request.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env bash

if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
exit 0;
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="$( dirname "$DIR" )"

Expand Down
2 changes: 2 additions & 0 deletions .ci/pull-request-check/xvfb-run-chrome
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
/usr/bin/xvfb-run /usr/bin/google-chrome $@
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI
on: [push, pull_request]
jobs:
build:
name: Lint, Check, Test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
with:
submodules: true

# We're in a shallow single-branch clone, so get the origin/master HEAD and more history
- run: git fetch origin master --depth=1
- run: git fetch --depth=25

- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 14

# Local via act
- name: Install packages for act
if: env.ACT == 'true'
run: apt update && apt install -y xvfb git

- name: Get current connector hash
id: get-connector-hash
run: |
echo "::set-output name=hash::$(git ls-remote https://github.com/zotero/zotero-connectors.git refs/heads/master | awk -F '\\s+' '{print $1}')"
shell: bash

- name: Cache connector code
id: connector-cache
uses: actions/cache@v2
with:
path: .ci/pull-request-check/connectors
key: connectors-${{ hashFiles('.ci/pull-request-check/check-pull-request.sh') }}-${{ steps.get-connector-hash.outputs.hash }}

- name: Install node packages
run: npm ci

#- name: Debugging with tmate
# uses: mxschmitt/[email protected]

- name: Lint
run: ./lint.sh
working-directory: .ci

- name: Check deleted.txt
run: ./checkDeletedTxt.sh
working-directory: .ci

- name: Test pull request
if: github.event_name == 'pull_request'
env:
BROWSER_EXECUTABLE: /home/runner/work/translators/translators/.ci/pull-request-check/xvfb-run-chrome
run: ./check-pull-request.sh
working-directory: .ci/pull-request-check
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

0 comments on commit 1c807c6

Please sign in to comment.