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

[wip] script to copy Coq's CI info into the platform #44

Draft
wants to merge 2 commits into
base: 2021.02
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: GitHub CI

on:
- pull_request
- push

env:
PLATFORM_ARGS: -extent=f -parallel=p -jobs=2 -vst=y -compcert=f
OPAM_VERSION: 2.0.6

jobs:
Windows:
runs-on: windows-latest

steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v2

- name: Run common platform script
shell: cmd
env:
COQREGTESTING: y
run: coq_platform_make_windows.bat -destcyg=C:\cygwin64_coq_platform -arch=64 %PLATFORM_ARGS%

Ubuntu:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install opam
run: |
sudo apt-get install bubblewrap build-essential
curl -L https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}/opam-${OPAM_VERSION}-x86_64-linux > opam.${OPAM_VERSION}
chmod a+x opam.${OPAM_VERSION}
sudo cp opam.${OPAM_VERSION} /usr/local/bin/opam.${OPAM_VERSION}
sudo ln -s /usr/local/bin/opam.${OPAM_VERSION} /usr/local/bin/opam

- name: Run common platform script
shell: bash
run: ./coq_platform_make.sh $PLATFORM_ARGS

Macos:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Install opam
run: |
curl -L https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}/opam-${OPAM_VERSION}-x86_64-macos > opam.${OPAM_VERSION}
chmod a+x opam.${OPAM_VERSION}
sudo cp opam.${OPAM_VERSION} /usr/local/bin/opam.${OPAM_VERSION}
sudo ln -s /usr/local/bin/opam.${OPAM_VERSION} /usr/local/bin/opam

- name: Run common platform script
shell: bash
run: ./coq_platform_make.sh $PLATFORM_ARGS
105 changes: 105 additions & 0 deletions shell_scripts/generate_coq_platform_packages_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env bash

set -e

# This script generates opam/packages/*/*.dev/opam files using Coq's CI
# project tracking info and generates $OUTPUT mentioning
# them
OUTPUT=${OUTPUT:=coq_platform_packages_ci.sh}

TMP=`mktemp -d`
trap "rm -rf $TMP" EXIT

function log {
echo $1
}

function git_clone {
test -d $TMP/git/$1 || (log "DBG: Cloning $1 ..."; git clone $2 -b $3 --depth=1 $TMP/git/$1 >/dev/null 2>&1)
}

function test_package {
printf "%-52s # %s\n" "PACKAGES=\"\${PACKAGES} $1.dev\"" "$2" >> $OUTPUT
}

function skip_package {
printf "#%-51s # %s\n" "PACKAGES=\"\${PACKAGES} $1.dev\"" "$2" >> $OUTPUT
}

function create_opam_pinned_package {
local cip="$1"
local package="$2"
local REPO_VAR="${cip}_CI_GITURL"
local REPO=${!REPO_VAR}
local BRANCH_VAR="${cip}_CI_REF"
local BRANCH=${!BRANCH_VAR}
git_clone $cip ${REPO} ${BRANCH}
mkdir -p opam/packages/$package/$package.dev/
if [ -e $TMP/git/$cip/$package.opam ]; then
cp $TMP/git/$cip/$package.opam opam/packages/$package/$package.dev/opam
elif [ -e $TMP/git/$cip/*.opam ]; then
Copy link
Member

Choose a reason for hiding this comment

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

What is the use case for this second case?

Could there be a default case where the opam file is taken from the coq-extra-dev repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes people call, in their repo, the opam file foo.opam instead of coq-foo, don't ask me why.

Yes, I thought about that, and maybe the ones in the usual repo should have precedence, and we should also look in the local repo with higher precedence... I think we should think carefully about these rule (I did not yet).

cp $TMP/git/$cip/*.opam opam/packages/$package/$package.dev/opam
elif [ -e $TMP/git/$cip/opam ]; then
cp $TMP/git/$cip/opam opam/packages/$package/$package.dev/opam
else
log "WARNING: No opam file for $cip $package"
skip_package $package "since no opam package found"
return
fi
local HASH=$(cd $TMP/git/$cip/ && git log --oneline | cut -f 1 -d ' ')
printf "\nsrc { url : \"%s\" }" "git+${REPO}#${HASH}" >> opam/packages/$package/$package.dev/opam
log "INFO: Testing $package at hash $HASH (on branch $BRANCH from $REPO)"
test_package $package "${REPO}#${HASH} (on branch $BRANCH)"
}

# fetch ci info for Coq
git_clone coq https://github.com/coq/coq.git master
. git/coq/dev/ci/ci-basic-overlay.sh
# fake ci project for Coq itself
project coq "https://github.com/coq/coq.git" "master"
COQ_CI_PROJECTS="${projects[*]}"

# fetch package list from the current platform
COQ_PLATFORM_EXTENT=f
COQ_PLATFORM_COMPCERT=f
COQ_PLATFORM_VST=y
. coq_platform_packages.sh

# create the .dev package and their list
> $OUTPUT
for pv in $PACKAGES; do
package=`echo $pv | sed -e 's/\..*//'`
case $package in
coqide)
create_opam_pinned_package coq $package
;;
coq-mathcomp-ssreflect|coq-mathcomp-fingroup|coq-mathcomp-algebra|coq-mathcomp-solvable|coq-mathcomp-field|coq-mathcomp-character)
create_opam_pinned_package mathcomp $package
;;
coq-hierarchy-builder) # https://github.com/coq/coq/pull/13633
create_opam_pinned_package elpi_hb $package
;;
coq-gappa) # https://github.com/coq/coq/pull/13633
create_opam_pinned_package gappa_plugin $package
;;
lablgtk3|gappa|menhir) # why are these in the platform?
continue
;;
*)
found=f
for cip in $COQ_CI_PROJECTS; do
if [ "$found" = "f" -a "${cip/_/-}" = "${package#coq-}" ]; then
found=t
create_opam_pinned_package ${cip} $package
fi
done
if [ "$found" = "f" ]; then
log "WARNING: platform package $package has no corresponding entry in Coq's ci"
skip_package $package "no corresponding entry in Coq's ci"
fi
;;
esac
done

echo "========================== platform version CI =================="
cat $OUTPUT