Skip to content

Commit

Permalink
Merge pull request #548 from neerdoc/unix_ci
Browse files Browse the repository at this point in the history
Github-based CI (Actions)
  • Loading branch information
jacebrowning committed Mar 4, 2022
2 parents 05d04f6 + 786e34f commit 116d73e
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 9 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches:
- develop
- master
pull_request:
# The branches below must be a subset of the branches above
branches:
- develop
- master
schedule:
- cron: '24 19 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
104 changes: 104 additions & 0 deletions .github/workflows/execute-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Execute tests

# This workflow is a reusable workflow. That is defined here.
on:
workflow_call:
# Require calling workflows to set variables that are OS dependent.
inputs:
architecture:
required: true
type: string
basepath:
required: true
type: string
os:
required: true
type: string
workpath:
required: true
type: string

# Define the jobs.
jobs:
# Execute tests.
test:
# Set which OS is used.
runs-on: ${{ inputs.os }}
# Define all python versions to test.
strategy:
fail-fast: false
matrix:
python-version: [ '3.7', '3.8', '3.9']
name: Python ${{ matrix.python-version }}

# Set the default working directory.
defaults:
run:
working-directory: ${{ inputs.workpath }}

# Define all job steps.
steps:
# Use a manual checkout.
- name: Checkout *nix
if: ${{ inputs.os != 'windows-latest' }}
run: |
mkdir -p ${{ inputs.workpath }}
git clone https://github.com/${{ github.repository }} ${{ inputs.workpath }} --depth 1 --branch $GITHUB_REF_NAME
# Use a manual checkout to force C: to be used on Windows. Otherwise some
# tests will fail due to default checkout is on D: while temporary paths
# are on C:.
- name: Checkout Windows
# Cannot start powershell from a path that does not exist, so change
# working directory for this step only.
working-directory: ${{ inputs.basepath }}
if: ${{ inputs.os == 'windows-latest' }}
run: |
mkdir -p ${{ inputs.workpath }}
git clone https://github.com/${{ github.repository }} ${{ inputs.workpath }} --depth 1 --branch $env:GITHUB_REF_NAME
# Create the matrix to test all defined python versions.
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ inputs.architecture }}

# Install poetry.
- name: Install poetry
run: pip install poetry

#####################################
# Install graphviz depending on OS. #
#####################################
# Mac OS X
- name: Install graphviz Mac OS X
if: ${{ inputs.os == 'macos-latest' }}
run: brew install graphviz

# Ubuntu
- name: Install graphviz Ubuntu
if: ${{ inputs.os == 'ubuntu-latest' }}
run: sudo apt install graphviz

# Windows
- name: Install graphviz Windows
if: ${{ inputs.os == 'windows-latest' }}
run: choco install graphviz
#####################################
# Done graphviz depending on OS. #
#####################################

# Check pre-requisites
- name: Check pre-requisites
run: make doctor

# Run the test suite. Reset to head when done.
- name: Run test
run: |
make test
git clean -f
git checkout .
# Run the full CI suite.
- name: Run full CI
run: make ci
17 changes: 17 additions & 0 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Linux Test

# Run on all pushes and PRs to 'develop'.
on:
push:
pull_request:
branches: [ develop ]

# Run on all pushes and PRs to 'develop'.
jobs:
test:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x64
basepath: '/home/runner/work'
os: 'ubuntu-latest'
workpath: '/home/runner/work/doorstop/doorstop'
17 changes: 17 additions & 0 deletions .github/workflows/test-osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Mac OS X Test

# Run on all pushes and PRs to 'develop'.
on:
push:
pull_request:
branches: [ develop ]

# Run on all pushes and PRs to 'develop'.
jobs:
test:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x64
basepath: '/Users/runner/work'
os: 'macos-latest'
workpath: '/Users/runner/work/doorstop/doorstop'
27 changes: 27 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Windows Test

# Run on all pushes and PRs to 'develop'.
on:
push:
pull_request:
branches: [ develop ]

# Call the reusable workflow.
jobs:
# Test 32-bit.
test-x86:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x86
basepath: 'D:\'
os: 'windows-latest'
workpath: 'C:\a\doorstop\doorstop'

# Test 64-bit.
test-x64:
uses: ./.github/workflows/execute-tests.yml
with:
architecture: x64
basepath: 'D:\'
os: 'windows-latest'
workpath: 'C:\a\doorstop\doorstop'
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![Linux Test](https://github.com/doorstop-dev/doorstop/actions/workflows/test-linux.yml/badge.svg)](https://github.com/doorstop-dev/doorstop/actions/workflows/test-linux.yml)
[![Mac OS X Test](https://github.com/doorstop-dev/doorstop/actions/workflows/test-osx.yml/badge.svg)](https://github.com/doorstop-dev/doorstop/actions/workflows/test-osx.yml)
[![Windows Test](https://github.com/doorstop-dev/doorstop/actions/workflows/test-windows.yml/badge.svg)](https://github.com/doorstop-dev/doorstop/actions/workflows/test-windows.yml)
<br>
[![Unix Build Status](https://img.shields.io/travis/com/doorstop-dev/doorstop/develop.svg?label=unix)](https://travis-ci.com/doorstop-dev/doorstop)
[![Windows Build Status](https://img.shields.io/appveyor/ci/jacebrowning/doorstop/develop.svg?label=windows)](https://ci.appveyor.com/project/jacebrowning/doorstop)
<br>
Expand Down
2 changes: 2 additions & 0 deletions doorstop/cli/tests/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

if "TRAVIS" in os.environ:
PATH = os.path.join(os.environ["VIRTUAL_ENV"], "bin", "doorstop")
elif "GITHUB_ACTIONS" in os.environ and os.name == "nt":
PATH = os.path.join(ROOT, ".venv", "Scripts", "doorstop")
elif os.name == "nt":
PATH = os.path.join(ROOT, ".venv", "Scripts", "doorstop.exe")
else:
Expand Down
9 changes: 0 additions & 9 deletions doorstop/core/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
import pprint
import shutil
import sys
import tempfile
import unittest
from unittest.mock import Mock, patch
Expand Down Expand Up @@ -573,10 +572,6 @@ def test_lines_markdown_document_without_child_links(self):
self.assertEqual(expected, text)
common.write_text(text, path)

@unittest.skipIf(
sys.version_info < (3, 9),
reason="Output format differs with older versions of Python",
)
def test_lines_html_document_linkify(self):
"""Verify HTML can be published from a document."""
path = os.path.join(FILES, "published.html")
Expand All @@ -589,10 +584,6 @@ def test_lines_html_document_linkify(self):
common.log.error(f"Published content changed: {path}")
common.write_text(actual, path)

@unittest.skipIf(
sys.version_info < (3, 9),
reason="Output format differs with older versions of Python",
)
@patch("doorstop.settings.PUBLISH_CHILD_LINKS", False)
def test_lines_html_document_without_child_links(self):
"""Verify HTML can be published from a document w/o child links."""
Expand Down

0 comments on commit 116d73e

Please sign in to comment.