Skip to content

Commit aba74d4

Browse files
committed
Add initial github actions
1 parent f6c9588 commit aba74d4

19 files changed

+259
-937
lines changed

.circleci/artifact_path

-1
This file was deleted.

.circleci/config.yml

-141
This file was deleted.

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
build_tools/* linguist-documentation=true
1+
.github/* linguist-documentation=true

.github/scripts/build_docs.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
# List available documentation versions
6+
python .github/scripts/list_versions.py > doc/versions.rst
7+
8+
make -C doc dist LATEXMKOPTS=-halt-on-error SPHINXOPTS=-T 2>&1 | tee doc-log.txt
9+
10+
# Insert the version warning for deployment
11+
find doc/_build/html/stable -name "*.html" |
12+
xargs sed -Ei 's,(<\/body>),<script src="https://scikit-optimize.github.io/versionwarning.js"></script>\1,'
13+
14+
15+
affected_doc_warnings() {
16+
files=$(git diff --name-only origin/master...HEAD)
17+
# Look for sphinx warnings only in files affected by the PR
18+
if [ -n "$files" ]
19+
then
20+
for af in ${files[@]}
21+
do
22+
warn+=`grep WARNING doc-log.txt | grep $af`
23+
done
24+
fi
25+
echo "$warn"
26+
}
27+
28+
echo "The following documentation warnings have been generated:"
29+
warnings=$(affected_doc_warnings)
30+
if [ -z "$warnings" ]
31+
then
32+
warnings="no warnings"
33+
fi
34+
echo "$warnings"

.github/scripts/publish_docs.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# Adapted from https://github.com/scikit-learn/scikit-learn/blob/master/build_tools/circle/push_doc.sh
3+
# The scikit-learn and scikit-optimize developers.
4+
# License: BSD-style
5+
#
6+
# This script is meant to be called in the "deploy" step.
7+
8+
set -eux
9+
10+
DOC_REPO="scikit-optimize.github.io"
11+
DOC_REPO_URL="https://:$GITHUB_TOKEN@github.com/scikit-optimize/$DOC_REPO"
12+
GENERATED_DOC_DIR=$1
13+
BRANCH="${GITHUB_REF#refs/*/}"
14+
BRANCH="${BRANCH:-master}"
15+
16+
if [[ -z "$GENERATED_DOC_DIR" ]]; then
17+
echo "Need to pass directory of the generated doc as argument"
18+
echo "Usage: $0 <generated_doc_dir>"
19+
exit 1
20+
fi
21+
22+
# Absolute path needed because we use cd further down in this script
23+
GENERATED_DOC_DIR=$(readlink -f $GENERATED_DOC_DIR)
24+
25+
if [ "$BRANCH" = "master" ]
26+
then
27+
dir=dev
28+
else
29+
# Strip off .X
30+
dir="${BRANCH%.*}"
31+
fi
32+
33+
MSG="Pushing docs to $dir/ for branch: $BRANCH, commit $GITHUB_SHA"
34+
35+
if [ ! -d $DOC_REPO ];
36+
then git clone "$DOC_REPO_URL"
37+
fi
38+
cd $DOC_REPO
39+
40+
# check if it's a new branch
41+
42+
if [ -d $dir ]
43+
then
44+
git rm -rf $dir/
45+
fi
46+
cp -R $GENERATED_DOC_DIR $dir
47+
git config user.email "[email protected]"
48+
git config user.name "skoptci"
49+
git config push.default matching
50+
git add -f $dir/
51+
git commit -m "$MSG" $dir
52+
git push
53+
echo $MSG

.github/workflows/ci.yml

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ master, main, ci/* ]
5+
tags: [ 'v[0-9]+\.[0-9]+.*' ]
6+
pull_request: { branches: [master] }
7+
schedule: [ cron: '20 16 * * 6' ]
8+
workflow_call:
9+
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
17+
steps:
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- uses: actions/cache@v2
23+
name: Set up caches
24+
with:
25+
path: ~/.cache/pip
26+
key: ${{ runner.os }}-py${{ matrix.python-version }}
27+
- name: Checkout repo
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 3
31+
- name: Install dependencies
32+
run: pip install flake8
33+
- name: flake8
34+
run: flake8 skopt/
35+
36+
test:
37+
name: Test
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
# When bumping, note to revise env.TEST_WITH_COVERAGE below
42+
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
43+
scikit-version: [ "1.1.3", "1.2.2", "1.3.2" ]
44+
45+
env:
46+
TEST_WITH_COVERAGE: ${{ matrix.python-version == '3.11' && matrix.scikit-version == '1.3.2' }}
47+
48+
steps:
49+
- name: Set up Python ${{ matrix.python-version }}
50+
uses: actions/setup-python@v4
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
54+
- name: Checkout repo
55+
uses: actions/checkout@v4
56+
57+
- name: Install dependencies
58+
run: |
59+
pip install -U pip wheel
60+
pip install scikit-learn==${{ matrix.scikit-version }}
61+
pip install .
62+
pip install .[dev,plots]
63+
python -c 'import skopt; print(skopt.__version__)'
64+
65+
- name: Test
66+
if: env.TEST_WITH_COVERAGE != 'true'
67+
run: |
68+
make test-code-parallel
69+
70+
- name: Test with Coverage
71+
if: env.TEST_WITH_COVERAGE == 'true'
72+
run: |
73+
make test-coverage
74+
bash <(curl -s https://codecov.io/bash)
75+
76+
- name: Upload artifact
77+
uses: actions/upload-artifact@v2
78+
with:
79+
name: package
80+
path: dist
81+
82+
docs:
83+
name: Docs
84+
runs-on: ubuntu-latest
85+
strategy:
86+
matrix:
87+
python-version: [ "3.11" ]
88+
env:
89+
MPLBACKEND: "agg"
90+
steps:
91+
- name: Set up Python ${{ matrix.python-version }}
92+
uses: actions/setup-python@v4
93+
with:
94+
python-version: ${{ matrix.python-version }}
95+
96+
- name: Checkout repo
97+
uses: actions/checkout@v4
98+
99+
- name: Install latex dependencies
100+
run: |
101+
sudo apt-get -yq update
102+
sudo apt-get -yq --no-install-recommends install \
103+
dvipng texlive-latex-base texlive-latex-extra \
104+
texlive-latex-recommended texlive-fonts-recommended \
105+
latexmk tex-gyre gsfonts ccache
106+
107+
- name: Install dependencies
108+
run: |
109+
pip install -U pip setuptools wheel
110+
pip install .[dev,doc,plots]
111+
112+
- name: Test docs
113+
run: |
114+
python -c 'import skopt; skopt.show_versions()'
115+
make test-doc
116+
make test-sphinxext
117+
make -C doc doctest
118+
make -C doc linkcheck
119+
120+
- name: Build docs
121+
run: |
122+
.github/scripts/build_docs.sh
123+
124+
- name: Upload artifact
125+
uses: actions/upload-artifact@v2
126+
with:
127+
name: docs
128+
path: doc/_build/html/stable

0 commit comments

Comments
 (0)