Skip to content

Commit

Permalink
Create action.yml (#75)
Browse files Browse the repository at this point in the history
* Create action.yml

* coverage action

* coverage test

* coverage test

* coverage test

* coverage test

* coverage test

* book

* book

* book

* Update book.yml

* constructing the book

* constructing the book

* constructing the book

* constructing the book

* constructing the book

* constructing the book

* constructing the book

* constructing the book

* notebook demo

* constructing the book

* constructing the book

* constructing the book
  • Loading branch information
tschm authored Jun 16, 2024
1 parent d215b92 commit 0852342
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 44 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Build book"

on:
push
#:
#branches:
# - main


jobs:
#runs-on: ubuntu-latest

# steps:
#sphinx:
# runs-on: "ubuntu-latest"
# steps:
# - uses: cvxgrp/.github/actions/sphinx@main
pdoc:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./actions/pdoc

test:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./actions/coverage

jupyter:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: ./actions/jupyter

book:
runs-on: "ubuntu-latest"
needs: [test, pdoc, jupyter]

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- uses: ./actions/book
22 changes: 22 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: coverage

on:
[push]

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- name: Set up Git repository
uses: actions/checkout@v4

- uses: ./actions/coverage
with:
source-folder: "cvx"

- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
files: artifacts/tests/coverage/coverage.info
format: lcov
2 changes: 1 addition & 1 deletion .github/workflows/deptry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
[push]

jobs:
run-deptry:
run-coverage-analysis:
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
.venv

.ipynb_checkpoints
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,35 @@ install: ## Install a virtual environment
python -m venv ${VENV}
${VENV}/bin/pip install --upgrade pip


.PHONY: fmt
fmt: install ## Run autoformatting and linting
${VENV}/bin/pip install pre-commit
${VENV}/bin/pre-commit install
${VENV}/bin/pre-commit run --all-files


.PHONY: build
build: install ## Build the book
${VENV}/bin/pip install jupyter-book
${VENV}/bin/jupyter-book clean book
${VENV}/bin/jupyter-book build book
touch book/_build/html/.nojekyll


.PHONY: clean
clean: ## Clean up caches and build artifacts
@git clean -X -d -f
@git branch -v | grep "\[gone\]" | cut -f 3 -d ' ' | xargs git branch -D


.PHONY: help
help: ## Display this help screen
@echo -e "\033[1mAvailable commands:\033[0m"
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort


.PHONY: jupyter
jupyter: install ## Run jupyter lab
@poetry run pip install jupyterlab
@poetry run jupyter lab
57 changes: 57 additions & 0 deletions actions/coverage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2023 Stanford University Convex Optimization Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Measure test coverage

description: "Test for coverage"

on:
workflow_call:
inputs:
source-folder:
description: 'Source folder'
type: string
required: false
default: 'cvx'

runs:
using: "composite"
steps:
- uses: cvxgrp/.github/actions/setup-environment@main

- name: Test on Linux
shell: bash
run: |
poetry run pip install --no-cache-dir \
pytest-cov \
pytest-html \
pytest-random-order
poetry run pytest --cov=${{ inputs.source-folder || 'cvx' }} --random-order --verbose \
--html=artifacts/tests/html-report/report.html \
--cov-report term \
--cov-report xml:artifacts/tests/coverage/coverage.xml \
--cov-report json:artifacts/tests/coverage/coverage.json \
--cov-report lcov:artifacts/tests/coverage/coverage.info \
--cov-report html:artifacts/tests/html-coverage \
tests/
# I want to upload the result to gh-pages, hence this file disturbs
rm -f artifacts/tests/html-coverage/.gitignore
- name: Archive tests results
uses: actions/upload-artifact@v4
with:
name: tests_coverage
path: artifacts/tests
retention-days: 1
2 changes: 1 addition & 1 deletion actions/jupyter/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ runs:

steps:
#- name: Check out repository
# uses: actions/checkout@v4
#- uses: actions/checkout@v4

- uses: cvxgrp/.github/actions/setup-environment@main

Expand Down
2 changes: 2 additions & 0 deletions actions/pdoc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ runs:
using: "composite"

steps:
#- uses: actions/checkout@v4

- uses: cvxgrp/.github/actions/setup-environment@main

- name: Install pdoc
Expand Down
45 changes: 3 additions & 42 deletions actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ on:
type: string
required: false
default: '3.11'
source-folder:
description: 'Source folder'
type: string
required: false
default: 'cvx'

runs:
using: "composite"
steps:
- uses: actions/checkout@v4

- uses: cvxgrp/.github/actions/setup-environment@main
with:
python-version: ${{ inputs.python-version || '3.11' }}
Expand All @@ -40,43 +37,7 @@ runs:
shell: bash
run: echo ${{ runner.os }}

- name: Test on Windows
if: ${{ runner.os == 'Windows' }}
- name: Test
shell: bash
run: |
poetry run pytest tests
- name: Test on macOS
if: ${{ runner.os == 'macOS' }}
shell: bash
run: |
poetry run pytest tests
- name: Test on Linux
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
poetry run pip install --no-cache-dir \
pytest-cov \
pytest-html \
pytest-random-order
poetry run pytest --cov=${{ inputs.source-folder || 'cvx' }} --random-order --verbose \
--html=artifacts/tests/html-report/report.html \
--cov-report term \
--cov-report xml:artifacts/tests/coverage/coverage.xml \
--cov-report json:artifacts/tests/coverage/coverage.json \
--cov-report lcov:artifacts/tests/coverage/coverage.info \
--cov-report html:artifacts/tests/html-coverage \
tests/
# I want to upload the result to gh-pages, hence this file disturbs
rm -f artifacts/tests/html-coverage/.gitignore
- name: Archive tests results
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v4
with:
name: tests_${{ inputs.python-version || '3.11' }}
path: artifacts/tests
retention-days: 1
34 changes: 34 additions & 0 deletions book/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html

title: .github
author: Thomas Schmelzer
only_build_toc_files: true

execute:
execute_notebooks: force
timeout: 240

parse:
myst_enable_extensions:
- linkify
- dollarmath

# needed for plotly
sphinx:
config:
html_js_files:
- https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js

# Information about where the book exists on the web
repository:
url: https://github.com/cvxgrp/.github
path_to_book: book
branch: main

# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
use_issues_button: true
use_repository_button: true
extra_navbar: Powered by <a href="https://jupyterbook.org">Jupyter Book</a> # Will be displayed underneath the left navbar.
6 changes: 6 additions & 0 deletions book/_toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Table of contents
# Learn more at https://jupyterbook.org/customize/toc.html
format: jb-book
root: docs/index
chapters:
- file: docs/api
1 change: 1 addition & 0 deletions book/docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# API
1 change: 1 addition & 0 deletions book/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Index
43 changes: 43 additions & 0 deletions book/docs/notebooks/.ipynb_checkpoints/demo-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "8a634d3c-32ff-47c0-a8fd-68b6a29b5fe7",
"metadata": {},
"source": [
"# Demo"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa5c8a21-6f51-4d36-a437-91702b65111c",
"metadata": {},
"outputs": [],
"source": [
"1 + 1"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
43 changes: 43 additions & 0 deletions book/docs/notebooks/demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "8a634d3c-32ff-47c0-a8fd-68b6a29b5fe7",
"metadata": {},
"source": [
"# Demo"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa5c8a21-6f51-4d36-a437-91702b65111c",
"metadata": {},
"outputs": [],
"source": [
"1 + 1"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 0852342

Please sign in to comment.