Skip to content

Commit

Permalink
setup ci
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Jan 8, 2024
1 parent 2b472ac commit ac41dda
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .ci/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -eu

cd "$(dirname "$0")"
cd .. # git root

if ! command -v sudo; then
# CI or Docker sometimes doesn't have it, so useful to have a dummy
function sudo {
"$@"
}
fi

if [ -n "${CI-}" ]; then
# install OS specific stuff here
case "$OSTYPE" in
darwin*)
# macos
:
;;
cygwin* | msys* | win*)
# windows
:
;;
*)
# must be linux?
src/dependencies.sh
;;
esac
fi


PY_BIN="python3"
# some systems might have python pointing to python3
if ! command -v python3 &> /dev/null; then
PY_BIN="python"
fi

# TODO
52 changes: 52 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# see https://github.com/karlicoss/pymplate for up-to-date reference

name: CI
on:
push:
branches: '*'
tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi
# Ideally I would put this in the pypi job... but github syntax doesn't allow for regexes there :shrug:
# P.S. fuck made up yaml DSLs.
pull_request: # needed to trigger on others' PRs
# Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them".
workflow_dispatch: # needed to trigger workflows manually
# todo cron?
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false


jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest]
emacs-version: ['whatever']
# vvv just an example of excluding stuff from matrix
# exclude: [{platform: macos-latest, python-version: '3.6'}]

runs-on: ${{ matrix.platform }}

steps:
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH

# - uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # nicer to have all git history when debugging/for tests

- uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

# explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd...
- run: bash .ci/run

3 changes: 2 additions & 1 deletion src/dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -eux
# apt update && apt full-upgrade?
apt update
apt full-upgrade -y
apt install -y entr # watching changes
apt install -y emacs-nox pandoc # TODO use latest emacs maybe?
apt install -y elpa-org elpa-dash elpa-s # TODO use latest org-mode maybe?
Expand Down

0 comments on commit ac41dda

Please sign in to comment.