Skip to content

Commit ddd014f

Browse files
authored
Merge pull request #14 from trishullab/usr/amit9oct/add-workflow
Added worklow
2 parents 83a77f5 + ce361fa commit ddd014f

File tree

7 files changed

+145
-7
lines changed

7 files changed

+145
-7
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build, Package, and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-test:
11+
runs-on: ubuntu-latest
12+
container:
13+
image: coqorg/coq:8.18.0-ocaml-4.14.2-flambda
14+
options: --user 0 # Running as root; no sudo needed
15+
env:
16+
HOME: /root
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
with:
22+
submodules: true # Ensure submodules are checked out
23+
24+
- name: Install Python and pip
25+
run: |
26+
apt-get update
27+
apt-get install -y python3 python3-pip
28+
ln -sf /usr/bin/python3 /usr/bin/python
29+
30+
- name: Check system Python version
31+
run: python --version
32+
33+
- name: Upgrade pip and install build tool
34+
run: |
35+
python -m pip install --upgrade pip --break-system-packages
36+
pip install build --break-system-packages
37+
38+
- name: Build package
39+
run: python -m build
40+
41+
- name: Install package
42+
run: pip install dist/*.whl --break-system-packages
43+
44+
- name: Check and Init opam version
45+
run: |
46+
opam --version
47+
opam init --disable-sandboxing --yes
48+
49+
- name: Install Coq
50+
run: |
51+
opam switch create simple_grp_theory 4.14.2
52+
opam switch simple_grp_theory
53+
eval $(opam env)
54+
opam repo add coq-released https://coq.inria.fr/opam/released
55+
opam pin add -y coq-lsp 0.1.8+8.18
56+
57+
- name: Install Lean (elan)
58+
shell: bash
59+
run: |
60+
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y
61+
source $HOME/.elan/env
62+
63+
- name: Prepare Lean REPL
64+
shell: bash
65+
run: |
66+
source $HOME/.elan/env
67+
install-lean-repl
68+
69+
- name: Build Lean REPL for itp-interface
70+
shell: bash
71+
run: |
72+
source $HOME/.elan/env
73+
install-itp-interface
74+
75+
- name: List repository files (debug step)
76+
run: find . -type f
77+
78+
- name: Run tests
79+
shell: bash
80+
run: |
81+
eval $(opam env)
82+
source $HOME/.elan/env
83+
python src/test/simple_env_test.py
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Enforce Main-to-Release Merges
2+
3+
on:
4+
pull_request:
5+
# This workflow will run for any PR whose base branch is "release"
6+
branches: [release]
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
check-source-branch:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check that PR comes from main branch
14+
run: |
15+
echo "PR head branch: ${{ github.event.pull_request.head.ref }}"
16+
if [ "${{ github.event.pull_request.head.ref }}" != "main" ]; then
17+
echo "Error: Only PRs originating from the 'main' branch can be merged into 'release'."
18+
exit 1
19+
fi
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
# This example triggers on any branch named "release"
6+
branches:
7+
- release
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write # Required for OIDC authentication
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
with:
20+
submodules: true # This ensures that all submodules are also checked out
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.10' # Adjust your Python version as needed
26+
27+
- name: Upgrade pip and install build tools
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install build twine
31+
32+
- name: Build package
33+
run: python -m build
34+
35+
- name: Publish package to PyPI via OIDC
36+
uses: pypa/[email protected]
37+
# Do not specify the `pypi-token` input so that the action uses OIDC authentication.
38+
# If you need to debug, you can set a token via secrets, but for OIDC leave it out.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,10 @@ file_path = "src/data/test/coq/custom_group_theory/theories/grpthm.v"
137137
# Create a switch for building the Coq project
138138
if os.system("opam switch simple_grp_theory") != 0:
139139
cmds = [
140-
'opam switch create simple_grp_theory 4.14.1',
140+
'opam switch create simple_grp_theory 4.14.2',
141141
'opam switch simple_grp_theory',
142142
'eval $(opam env)',
143143
'opam repo add coq-released https://coq.inria.fr/opam/released',
144-
'opam pin add -y coq 8.18.0',
145144
'opam pin add -y coq-lsp 0.1.8+8.18'
146145
]
147146
final_cmd = ' && '.join(cmds)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = [
1111
]
1212
description = "Generic interface for hooking up to any Interactive Theorem Prover (ITP) and collecting data for training ML models for AI in formal theorem proving."
1313
readme = "README.md"
14-
requires-python = ">=3.10, <3.13"
14+
requires-python = ">=3.9, <3.13"
1515
classifiers = [
1616
"Programming Language :: Python :: 3",
1717
"License :: OSI Approved :: MIT License",

src/itp_interface/main/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def install_lean_repl():
5757
break
5858
# Make sure that .elan is installed
5959
print("Checking if .elan is installed")
60-
if os.path.exists(os.path.expanduser("~/.elan")):
60+
if os.system("elan --version") == 0:
6161
print("[OK] .elan is installed")
6262
else:
6363
print("Installing .elan")

src/test/simpl_env_test.py renamed to src/test/simple_env_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ def build_coq_project(self, project_folder):
2121
except:
2222
self.current_switch = None
2323
# Check if the switch exists
24-
# opam switch create simple_grp_theory 4.14.1
24+
# opam switch create simple_grp_theory 4.14.2
2525
if os.system("opam switch simple_grp_theory") != 0:
2626
cmds = [
27-
'opam switch create simple_grp_theory 4.14.1',
27+
'opam switch create simple_grp_theory 4.14.2',
2828
'opam switch simple_grp_theory',
2929
'eval $(opam env)',
3030
'opam repo add coq-released https://coq.inria.fr/opam/released',
31-
'opam pin add -y coq 8.18.0',
3231
'opam pin add -y coq-lsp 0.1.8+8.18'
3332
]
3433
final_cmd = ' && '.join(cmds)

0 commit comments

Comments
 (0)