Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Introducing new workflow: Building K from source in MacOS #3674

Closed
wants to merge 12 commits into from
156 changes: 156 additions & 0 deletions .github/workflows/test-pr-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: "Test PR on MacOS"
on:
pull_request:
types: [opened, edited, reopened, synchronize]
branches:
- "develop"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
version-sync:
name: "Version Sync"
runs-on: ubuntu-20.04
steps:
- name: "Check out code"
uses: actions/checkout@v3
with:
token: ${{ secrets.JENKINS_GITHUB_PAT }}
# fetch-depth 0 means deep clone the repo
fetch-depth: 0
- name: "Update Version"
run: |
set -x
git config user.name devops
git config user.email [email protected]
./package/version.sh sub
if git add --update && git commit --message "Set Version: $(cat package/version)"; then
git push origin HEAD:${GITHUB_HEAD_REF}
fi

nix-maven:
name: "Maven Build"
strategy:
fail-fast: false
matrix:
include:
- runner: macos-13
os: macos-13
- runner: MacM1
os: self-macos-12
runs-on: ${{ matrix.runner }}
needs: version-sync
steps:
- name: "Check out code, set up Git"
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: "Upgrade bash"
if: ${{ contains(matrix.os, 'macos') }}
run: brew install bash
- name: "Install Dependencies"
run: brew install bison boost cmake flex fmt gcc gmp openjdk jemalloc libyaml llvm@15 make maven mpfr pkg-config python stack zlib z3
- name: "Install and set up direnv"
run: |
set -euxo pipefail
export PATH="$(brew --prefix bison)/bin:$PATH"
export PATH="$(brew --prefix flex)/bin:$PATH"
export PATH="$(brew --prefix llvm@15)/bin:$PATH"
export PATH="$(brew --prefix openjdk)/bin:$PATH"
echo $(which llvm-config)
export LLVM_CONFIG=$(which llvm-config)
export LLVM_DIR="$(brew --prefix llvm@15)/lib/cmake/"
mvn package -T1C
# brew install direnv
# cp macos-envrc .envrc
# eval "$(direnv hook bash)"
# direnv allow .
Comment on lines +66 to +69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're reaching that conclusion, but direnv is not something I'd expect to see in CI - it's just a local developer convenience tool.

Copy link
Collaborator Author

@Robertorosmaninho Robertorosmaninho Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't quite follow what you mean by

the Homebrew formula is in general a pretty good source for the best way to build K from source on macOS

Could you please elaborate on that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is here: https://github.com/kframework/homebrew-k/blob/master/Formula/kframework.rb

If you've not seen a Homebrew formula before, it's basically a Ruby DSL that allows you to specify dependencies and build steps for a package. We maintain one for K; if there are macOS-specific issues with the build then it's plausible that the Homebrew code has already dealt with it somehow

- name: "Build K from Source"
run: |
set -euxo pipefail
LLVM_CONFIG=$(which llvm-config) mvn package -T1C

test-k:
name: "K Tests"
strategy:
fail-fast: false
matrix:
include:
- runner: macos-13
os: macos-13
- runner: MacM1
os: self-macos-12
runs-on: ${{ matrix.runner }}
needs: version-sync
steps:
- name: "Check out code"
uses: actions/checkout@v3
with:
submodules: recursive
- name: "Build and Test K"
run: mvn verify --batch-mode -U
- name: "Check out k-exercises"
uses: actions/checkout@v3
with:
repository: runtimeverification/k-exercises
token: ${{ secrets.JENKINS_GITHUB_PAT }}
submodules: recursive
path: k-exercises
- name: "Tutorial Integration Tests"
run: |
k-distribution/target/release/k/bin/spawn-kserver kserver.log
cd k-exercises/tutorial && make -j`nproc` --output-sync
cd ../../k-distribution/k-tutorial/1_basic && ./test_kompile.sh'
cd ../2_intermediate && ./test_kompile.sh'

# performance-tests:
# name: 'Performace Tests'
# runs-on: [self-hosted, linux, performance]
# needs: test-package-ubuntu-jammy
# steps:
# - uses: actions/checkout@v3
# - name: 'Download K package from the Summary Page'
# uses: actions/download-artifact@v3
# with:
# name: kframework.deb
# - name: 'Set up Docker Test Image'
# env:
# BASE_OS: ubuntu
# BASE_DISTRO: jammy
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
# BENCHER_PROJECT: k-framework
# BENCHER_ADAPTER: json
# run: |
# set -euxo pipefail
# workspace=$(pwd)
# docker run --name k-profiling-tests-${GITHUB_SHA} \
# --rm -it --detach \
# -e BENCHER_API_TOKEN=$BENCHER_API_TOKEN \
# -e BENCHER_PROJECT=$BENCHER_PROJECT \
# -e BENCHER_ADAPTER=$BENCHER_ADAPTER \
# -e GITHUB_HEAD_REF=$GITHUB_HEAD_REF \
# -e GITHUB_BASE_REF=$GITHUB_BASE_REF \
# -e GITHUB_TOKEN=$GITHUB_TOKEN \
# -e GITHUB_ACTIONS=true \
# -e GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME \
# -e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
# -e GITHUB_REF=$GITHUB_REF \
# --workdir /opt/workspace \
# -v "${workspace}:/opt/workspace" \
# ${BASE_OS}:${BASE_DISTRO}
# - name: 'Install K from Package'
# run: |
# set -euxo pipefail
# docker exec -t k-profiling-tests-${GITHUB_SHA} /bin/bash -c './k-distribution/tests/profiling/setup_profiling.sh'
# - name: 'Profiling Performance Tests'
# run: |
# set -euxo pipefail
# docker exec -t k-profiling-tests-${GITHUB_SHA} /bin/bash -c 'cd k-distribution/tests/profiling && make'
# - name: 'Tear down Docker'
# if: always()
# run: |
# docker stop --time=0 k-profiling-tests-${GITHUB_SHA}
# docker container rm --force k-profiling-tests-${GITHUB_SHA} || true