Skip to content

Commit

Permalink
chore: Implement makim and containers-sugar (arxlang#85)
Browse files Browse the repository at this point in the history
* chore: Implement makim and containers-sugar

* Change make calls to makim

* Add makim to conda build env file

* Fix conda build env file typo

* fix makim file and upgrade makim to 1.3

* fix dependencies without group prefix

* Add workflow for containers

* Update depds and improve ci for containers

* update containers sugar pinning

* create env file on ci

* show .env file for the containers workflow

* Fix .env creation

* update makim pinning

* update containers-sugar

* fix conda build

* Remove shell_app and move extras to args
  • Loading branch information
xmnlab authored Feb 17, 2023
1 parent 2731d0e commit 705ce92
Show file tree
Hide file tree
Showing 19 changed files with 345 additions and 218 deletions.
11 changes: 11 additions & 0 deletions .containers-sugar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1.0.0
compose-app: docker-compose
service-groups:
- name: default
project-name: arx
compose-path: containers/compose.yaml
env-file: .env
services:
default: arx
list:
- name: arx
2 changes: 1 addition & 1 deletion .github/workflows/conda-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
environment-file: conda/build.yaml

- name: build using conda
run: make conda-build
run: makim conda.build
53 changes: 53 additions & 0 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: containers

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
containers:

runs-on: ubuntu-latest
timeout-minutes: 20

concurrency:
group: ci-containers-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive


- uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.9
miniforge-variant: Mambaforge
channels: conda-forge,nodefaults
channel-priority: true
activate-environment: arx-containers
environment-file: conda/containers.yaml

- name: create a dot env file
run: |
makim env.create-file
cat .env
- name: build container
run: containers-sugar build

- name: run container
run: |
# TODO: build arx using containers-sugar
containers-sugar run --services arx --extras='--rm' --cmd "makim build.release"
14 changes: 7 additions & 7 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ jobs:
environment-file: conda/dev-linux-64.yaml

- name: build
run: make build-dev CLEAN=1
run: makim build.dev --clean

- name: test flags
run: |
build/arx --version
run: build/arx --version

- name: run sanity tests
run: make test-sanitizer
run: makim tests.sanitizer

- name: run example tests
run: make test-examples
run: makim tests.examples

- name: lint
if: success() || failure()
run: |
pre-commit install
pre-commit run --all-files
makim tests.lint
- name: llvm-cov generation
if: ${{ github.event_name == 'pull_request' }}
id: llvm-cov-report
run: make code-coverage
run: makim tests.code-coverage

- name: Check if PR title is a correct semantic-release prefix
if: ${{ github.event_name == 'pull_request' && always() }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ jobs:
run: mamba env update -n arx --file conda/release.yaml

- name: build code
run: make build
run: makim build.release

- name: Test documentation generation
run: make docs-build
run: makim docs.build

- name: Test release
if: ${{ github.event_name != 'workflow_dispatch' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make release-dry
run: makim release.dry

# note: semantic-release should be executed before the documentation
# publishing because semantic-release will update changelog and
Expand All @@ -58,11 +58,11 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make release
run: makim release.ci

- name: Generate documentation with changes from semantic-release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: make docs-build
run: makim docs.build

- name: GitHub Pages action
if: ${{ github.event_name == 'workflow_dispatch' }}
Expand Down
212 changes: 212 additions & 0 deletions .makim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
version: 1.0.0
groups:
- name: build
targets:
clean-gcda:
help: Remove temporary gcda files
run: |
touch tmp.gcda
find . -name "*.gcda" -print0 | xargs -0 rm
clean:
help: Remove all unnecessary temporary files
dependencies:
- target: build.clean-gcda
run: |
rm -rf build/*
rm -f bin/*
mkdir -p build
install:
help: Install Arx locally
run: meson install -C build

release:
help: Build Arx for release
env:
ASAN_OPTIONS: '{{ args.asan_options }}'
args:
asan-options:
help: |
Define a custom value for the environment variable
`ASAN_OPTIONS`
type: string
default: ''
build-type:
help: |
Define the build type, options are:
plain, debug, debugoptimized, release, minsize, and custom
type: string
default: release
clean:
help: Clean temporary files before the building step
type: bool
action: store_true
extras:
help: Extra arguments for the build step
type: string
default: ''
dependencies:
- target: build.clean
if: {{ args.clean }}
run: |
meson setup \
--prefix $CONDA_PREFIX \
--libdir $CONDA_PREFIX/lib \
--includedir $CONDA_PREFIX/include \
--buildtype={{ args.build_type }} \
--native-file meson.native {{ args.extras }} \
build .
meson compile -C build
dev:
help: Build for development (+tests +debug)
args:
clean:
help: Clean temporary files before the building step
type: bool
action: store_true
dependencies:
- target: build.release
args:
build-type: "debug"
extras: "-Ddev=enabled -Db_coverage=true -Doptimization=0"
clean: {{ args.clean }}
asan-options: "fast_unwind_on_malloc=0"

- name: env
targets:
create-file:
help: Create a .env file
run: |
touch .env
echo -n @("HOST_UID=" + $(id -u) + "HOST_GID=" + $(id -g)) > .env
- name: conda
targets:
build:
help: Create the conda package for arx
run: |
cd conda/recipe
conda build purge
conda mambabuild .
- name: release
vars:
app: |
npx --yes \
-p semantic-release \
-p "@semantic-release/commit-analyzer" \
-p "@semantic-release/release-notes-generator" \
-p "@semantic-release/changelog" \
-p "@semantic-release/exec" \
-p "@semantic-release/github" \
-p "@semantic-release/git" \
-p "@google/semantic-release-replace-plugin" \
semantic-release
targets:
ci:
help: Run semantic-release on CI
run: {{ app }} --ci

dry:
help: Run semantic-release on CI for tests in dry-run mode.
run: {{ app }} --dry-run

- name: docs
targets:
api:
help: Build API docs
run: |
mkdir -p build
doxygen Doxyfile
./scripts/format_releases.sh
build:
help: Build the general docs pages
dependencies:
- target: docs.clean
- target: docs.api
run: |
mkdocs build --config-file docs/mkdocs.yaml --dirty --site-dir build
echo "arxlang.org" > ./build/CNAME
clean:
help: Clean temporary documentation files
run: rm -rf ./build

preview:
help: Preview documentation result locally
dependencies:
- target: docs.clean
- target: docs.api
run: mkdocs serve --config-file docs/mkdocs.yaml --watch docs

- name: tests
targets:
sanitizer:
help: Run sanitizer tests
run: meson test -C build -v

code-coverage:
help: Check code coverage by tests
run: ninja coverage -C build

gen-object:
help: Run test for object generation
extras:
help: Extra arguments for the build step
type: string
default: ''
run: ./tests/scripts/test-gen-objects.sh {{ args.extras }}

gen-ast:
help: Run test for AST generation
extras:
help: Extra arguments for the build step
type: string
default: ''
run: ./tests/scripts/test-gen-ast.sh {{ args.extras }}

gen-llvm-ir:
help: Run test for LLVM IR
extras:
help: Extra arguments for the build step
type: string
default: ''
run: ./tests/scripts/test-gen-ast.sh {{ args.extras }}

examples:
help: Test all code generation for the example arx files
dependencies:
- target: tests.gen-object
- target: tests.gen-ast
- target: tests.gen-llvm-ir

all:
help: Run sanitizer tests and code generation for examples
dependencies:
- target: tests.sanitizer
- target: tests.examples

lint:
help: Run linter tools
run: pre-commit run --all-files --verbose

- name: debug
targets:
fibonacci:
help: Debug arx via an example file (fibonacci)
args:
extras:
help: Extra arguments for the build step
type: string
default: ''
run: |
LSAN_OPTIONS=verbosity=1:log_threads=1 gdb \
--args build/arx \
--input `pwd`/examples/fibonacci.arx \
--output "/tmp/fibonacci" {{ args.extras }}
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
We as members, contributors, and leaders pledge to makim participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
Expand Down
Loading

0 comments on commit 705ce92

Please sign in to comment.