From 275702edd5df5d2dda86ccd7ff341732a11d83a9 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 26 Sep 2019 18:32:59 +0100 Subject: [PATCH] Ci/GitHub actions (#7822) Merge pull request 7822 --- .gitattributes | 1 + .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++ test/helper.rb | 11 ++++++++++ test/source/.gitattributes | 1 + test/test_site.rb | 8 ++------ 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 test/source/.gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..176a458f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1b6fcb99 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: Continuous Integration + +on: + push: + branches: + - master + - /.*-stable/ + pull_request: + branches: + - master + - /.*-stable/ + +jobs: + ci: + name: 'SUITE: ${{ matrix.test_suite }} / OS: ${{ matrix.os }}' + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + test_suite: + - test + - default-site + os: + - ubuntu-latest + - windows-latest + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Set up Ruby 2.6 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.6.x + - name: 'Update Rubygems & Bundler' + run: 'gem update --system --no-document && gem update bundler --no-document' + - name: Set up bundle + run: bundle install --jobs 4 --retry 3 + - name: Run Test Suite + run: bash script/cibuild + env: + CI: true + TEST_SUITE: ${{ matrix.test_suite }} diff --git a/test/helper.rb b/test/helper.rb index c4bf5b1d..33e52f19 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -80,6 +80,17 @@ module DirectoryHelpers def test_dir(*subdirs) root_dir("test", *subdirs) end + + def temp_dir(*subdirs) + if Utils::Platforms.windows? + drive = Dir.pwd.sub(%r!^([^\/]+).*!, '\1') + temp_root = File.join(drive, "tmp") + else + temp_root = "/tmp" + end + + File.join(temp_root, *subdirs) + end end class JekyllUnitTest < Minitest::Test diff --git a/test/source/.gitattributes b/test/source/.gitattributes new file mode 100644 index 00000000..fa1385d9 --- /dev/null +++ b/test/source/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/test/test_site.rb b/test/test_site.rb index 70614fde..122490e8 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -32,7 +32,7 @@ class TestSite < JekyllUnitTest should "have an array for plugins if passed as a string" do site = Site.new(site_configuration("plugins_dir" => "/tmp/plugins")) - array = Utils::Platforms.windows? ? ["C:/tmp/plugins"] : ["/tmp/plugins"] + array = [temp_dir("plugins")] assert_equal array, site.plugins end @@ -40,11 +40,7 @@ class TestSite < JekyllUnitTest site = Site.new(site_configuration( "plugins_dir" => ["/tmp/plugins", "/tmp/otherplugins"] )) - array = if Utils::Platforms.windows? - ["C:/tmp/plugins", "C:/tmp/otherplugins"] - else - ["/tmp/plugins", "/tmp/otherplugins"] - end + array = [temp_dir("plugins"), temp_dir("otherplugins")] assert_equal array, site.plugins end