Skip to content

Commit

Permalink
Set up continuous integration
Browse files Browse the repository at this point in the history
  • Loading branch information
liammulh committed Jun 26, 2024
1 parent ac5d420 commit 890e6b4
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 33 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: continuous integration
on: [push, pull_request]
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go 1.22
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: install Pipenv
run: pip install pipenv --user
- name: install dependencies
run: pipenv sync --dev # Installs all deps, including dev deps, from Pipfile.lock.
- name: Create .env file for GitHub Actions
run: pipenv run invoke mkenv
- name: format
run: pipenv run invoke fmt
- name: lint
run: pipenv run invoke lint
- name: check types
run: pipenv run invoke build
- name: run tests
run: pipenv run invoke test
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PA
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
OTHER DEALINGS IN THE SOFTWARE.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Human Leukocyte Antigen (HLA) Curation Interface

[![CI](https://github.com/clingen/stanford-hci/actions/workflows/check.yml/badge.svg)](https://github.com/clingen/stanford-hci/actions)

The HCI is under development. See our [roadmap](https://github.com/ClinGen/stanford-hci/issues/1)
and our [docs](./doc).
and our [docs](./doc).
40 changes: 20 additions & 20 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Documentation

- [Tutorials](./tutorial.md) (learning-oriented)
- Tutorials are lessons that take the reader by the hand through a series of
steps to complete a project of some kind. Unlike how-to guides, tutorials
don't assume lots of prerequisite knowledge.
- Tutorials are lessons that take the reader by the hand through a series of
steps to complete a project of some kind. Unlike how-to guides, tutorials
don't assume lots of prerequisite knowledge.
- [How-to guides](./howto.md) (problem-oriented)
- How-to guides take the reader through the steps required to solve a
real-world problem. They are recipes, directions to achieve a specific end.
Unlike tutorials, they typically assume a fair amount of prerequisite
knowledge.
- How-to guides take the reader through the steps required to solve a
real-world problem. They are recipes, directions to achieve a specific end.
Unlike tutorials, they typically assume a fair amount of prerequisite
knowledge.
- [Explanations](./explanation.md) (understanding-oriented)
- Explanation, or discussions, clarify and illuminate a particular topic. They
broaden the documentation’s coverage of a topic. Explanations can equally
well be described as discussions; they are discursive in nature. They are a
chance for the documentation to relax and step back from the software,
taking a wider view, illuminating it from a higher level or even from
different perspectives. You might imagine a discussion document being read
at leisure, rather than over the code.
- Explanation, or discussions, clarify and illuminate a particular topic. They
broaden the documentation’s coverage of a topic. Explanations can equally
well be described as discussions; they are discursive in nature. They are a
chance for the documentation to relax and step back from the software,
taking a wider view, illuminating it from a higher level or even from
different perspectives. You might imagine a discussion document being read
at leisure, rather than over the code.
- Reference guides (information-oriented)
- Reference guides are technical descriptions of the machinery and how to
operate it. Reference guides have one job only: to describe. They are
code-determined, because ultimately that’s what they describe: key classes,
functions, APIs, and so they should list things like functions, fields,
attributes and methods, and set out how to use them. For this project,
reference is code comments (Go doc comments).
- Reference guides are technical descriptions of the machinery and how to
operate it. Reference guides have one job only: to describe. They are
code-determined, because ultimately that’s what they describe: key classes,
functions, APIs, and so they should list things like functions, fields,
attributes and methods, and set out how to use them. For this project,
reference is code comments (Go doc comments).
2 changes: 1 addition & 1 deletion doc/explanation.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Explanations
# Explanations
2 changes: 1 addition & 1 deletion doc/howto.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# How-to guides
# How-to guides
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Tutorials
# Tutorials
26 changes: 18 additions & 8 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
All command line tasks should be defined in this file. The only
exception to this is managing dependencies.
All commands in this file assume you're in the root directory and
All commands in this file assume you're in the root directory, and
you've activated the virtual environment.
"""

import os

# Invoke always requires a context parameter, even if it ends up going
# unused. As of this writing, there are a handful of tasks that don't
# use their context parameters.
Expand All @@ -27,16 +29,15 @@
TEMPLATE_CONF = dotenv_values(ENV_TEMPLATE)
ACTUAL_CONF = dotenv_values(ENV_ACTUAL)

# Absolute paths to src and build directories:
SRC_DIR = f"{ACTUAL_CONF['HCI_ROOT_DIR']}/src"
BUILD_DIR = f"{ACTUAL_CONF['HCI_ROOT_DIR']}/build"


@task
def fmt(c):
"""Format code."""
c.run("go fmt ./...")
c.run("black tasks.py")
if not os.getenv("GITHUB_ACTIONS"):
c.run("yamlfmt ./.github/**/*")
c.run("mdformat .")


@task
Expand All @@ -49,13 +50,13 @@ def lint(c):
@task
def clean(c):
"""Remove old binary."""
c.run(f"rm -rf {BUILD_DIR}/*")
c.run("rm -rf build/*")


@task
def build(c):
"""Build the binary."""
c.run(f"go build -o {BUILD_DIR}/hci {SRC_DIR}")
c.run("go build -o build/hci ./src")


@task
Expand Down Expand Up @@ -86,4 +87,13 @@ def check(c):
@task
def dev(c):
"""Run the development server."""
c.run(f"source {ENV_ACTUAL} && go run {SRC_DIR}/main.go")
c.run(f"source {ENV_ACTUAL} && go run src/main.go")


@task
def mkenv(c):
"""Make a .env file for GitHub Actions."""
c.run("touch ${GITHUB_WORKSPACE}/.env")
c.run(
"echo \"export HCI_ROOT_DIR='$GITHUB_WORKSPACE'\" >> ${GITHUB_WORKSPACE}/.env"
)

0 comments on commit 890e6b4

Please sign in to comment.