Skip to content

Commit 77b8f68

Browse files
authored
Merge pull request #62 from coq/staging
Staging branch support
2 parents b056ad8 + f4cf3c9 commit 77b8f68

File tree

7 files changed

+58
-15
lines changed

7 files changed

+58
-15
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: opam exec -- dune build @install
5757

5858
- name: Run tests
59-
run: opam exec -- dune test
59+
run: opam exec -- make test
6060

6161
# - name: Format code
6262
# run: opam exec -- dune build --auto-promote @fmt

.github/workflows/debug-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: opam exec -- dune build @install
5050

5151
- name: Run tests
52-
run: opam exec -- dune test
52+
run: opam exec -- make test
5353

5454
- name: Format code
5555
run: opam exec -- dune build --auto-promote @fmt

Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ WORKDIR /home/opam
1212
ADD rocqproverorg.opam rocqproverorg.opam
1313
RUN opam install . --deps-only
1414

15+
# Git commit and branch information
1516
ARG GIT_COMMIT
1617
RUN echo "Based on commit: $GIT_COMMIT"
1718
ENV GIT_COMMIT=${GIT_COMMIT}
1819
LABEL rocqproverorg=${GIT_COMMIT}
1920

21+
ARG GIT_BRANCH
22+
RUN echo "Based on branch: $GIT_BRANCH"
23+
ENV GIT_BRANCH=${GIT_BRANCH}
24+
LABEL rocqproverorg_branch=${GIT_BRANCH}
25+
2026
# Build project
2127
COPY --chown=opam:opam . .
2228
RUN opam exec -- dune build @install --profile=release
@@ -37,6 +43,11 @@ RUN echo "Based on commit: $GIT_COMMIT"
3743
ENV GIT_COMMIT=${GIT_COMMIT}
3844
LABEL rocqproverorg=${GIT_COMMIT}
3945

46+
ARG GIT_BRANCH
47+
RUN echo "Based on branch: $GIT_BRANCH"
48+
ENV GIT_BRANCH=${GIT_BRANCH}
49+
LABEL rocqproverorg_branch=${GIT_BRANCH}
50+
4051
RUN apk update && apk add --update libev gmp git
4152

4253
RUN chmod -R 755 /var

Makefile

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
.DEFAULT_GOAL := all
2-
DOC_PATH=`pwd`/rocq-doc/
3-
GIT_HEAD=`git rev-parse HEAD`
4-
GIT_COMMIT=${GIT_HEAD}`git diff --quiet HEAD || echo "-dirty"`
2+
DOC_PATH=$(shell pwd)/rocq-doc/
3+
GIT_HEAD=$(shell git rev-parse HEAD)
4+
GIT_DIRTY=$(shell git diff --quiet HEAD || echo "-dirty")
5+
GIT_COMMIT=${GIT_HEAD}${GIT_DIRTY}
6+
GIT_BRANCH=$(shell git branch --show-current)
7+
8+
export GIT_COMMIT
9+
export GIT_BRANCH
510

611
.PHONY: all
712
all:
@@ -11,6 +16,7 @@ all:
1116
show-config:
1217
@echo "DOC_PATH="${DOC_PATH}
1318
@echo "GIT_COMMIT="${GIT_COMMIT}
19+
@echo "GIT_BRANCH="${GIT_BRANCH}
1420

1521
.PHONY: deps
1622
deps: create_switch ## Install development dependencies
@@ -72,7 +78,7 @@ fmt: ## Format the codebase with ocamlformat
7278

7379
.PHONY: watch
7480
watch: update-local-doc ## Watch for the filesystem and rebuild on every change
75-
DOC_PATH=${DOC_PATH} GIT_COMMIT=${GIT_COMMIT} opam exec -- dune build @run -w --force --no-buffer
81+
opam exec -- dune build @run -w --force --no-buffer
7682

7783
.PHONY: utop
7884
utop: ## Run a REPL and link with the project's libraries
@@ -85,7 +91,7 @@ scrape: ## Generate the po files
8591

8692
.PHONY: docker
8793
docker: ## Generate docker container
88-
docker build --build-arg GIT_COMMIT=`git rev-parse HEAD` -f Dockerfile . -t rocqproverorg:latest
94+
docker build --build-arg GIT_COMMIT=${GIT_COMMIT} --build-arg GIT_BRANCH=${GIT_BRANCH} -f Dockerfile . -t rocqproverorg:latest
8995

9096
.PHONY: linkcheck
9197
linkcheck:

compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
context: .
66
args:
77
- GIT_COMMIT=${GIT_COMMIT}
8+
- GIT_BRANCH=${GIT_BRANCH}
89
ports:
910
- "127.0.0.1:${LOCAL_PORT}:8080"
1011
volumes:

src/rocqproverorg_frontend/components/footer.eml

+7-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,13 @@ let primary_footer () =
173173
<div class="flex w-full md:hidden">
174174
<%s! LightDarkModeSwitch.render %>
175175
</div>
176-
<div class="flex mt-6 space-y-4">
177-
<% let commit = try Sys.getenv "GIT_COMMIT" with Not_found -> failwith "Environment variable GIT_COMMIT is not set" in %>
178-
<%s! link ~href:("https://github.com/coq/rocq-prover.org/commit/" ^ commit) ~name:"GitHub Source" %>
176+
<div class="flex mt-6 space-y-4 hidden">
177+
<% let commit = try Sys.getenv "GIT_COMMIT" with Not_found -> failwith "Environment variable GIT_COMMIT is not set" in
178+
let branch = try Sys.getenv "GIT_BRANCH" with Not_found -> failwith "Environment variable GIT_BRANCH is not set" in %>
179+
<div class="text-base leading-6 text-content dark:text-dark-title">
180+
GitHub <a href="https://github.com/coq/rocq-prover.org/tree/<%s branch %>" class="text-base leading-6 text-content dark:text-dark-title hover:text-primary dark:hover:text-dark-primary">branch</a>
181+
and <a href="https://github.com/coq/rocq-prover.org/commit/<%s commit %>">commit</a>.
182+
</div>
179183
<% ; %>
180184
</div>
181185
</div>

src/rocqproverorg_frontend/components/header.eml

+26-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ let url_of_nav_item = function
2727

2828
let nav_items = [ Learn; Platform; Packages; Community; Consortium; News; Playground ]
2929

30+
let git_branch = try Sys.getenv "GIT_BRANCH" with Not_found -> failwith "Environment variable GIT_BRANCH is not set"
31+
let git_commit = try Sys.getenv "GIT_COMMIT" with Not_found -> failwith "Environment variable GIT_COMMIT is not set"
32+
let git_short_commit = if String.length git_commit > 6 then String.sub git_commit 0 7 else git_commit
33+
3034
let menu_link
3135
~(active: bool)
3236
~href
@@ -50,8 +54,27 @@ let search_dropdown () =
5054
</a>
5155
in
5256
<header
53-
class="fixed top-0 z-50 w-full h-20 flex items-center "
54-
x-data="{ open: false }">
57+
class="fixed top-0 z-50 w-full h-20 flex items-center flex-wrap"
58+
x-data="{ open: false }">
59+
<% if git_branch <> "main" then (%>
60+
<div id="alert-border-2" class="bg-primary_25 border-secondary border-t-4 bottom-0 dark:bg-dark-card fixed flex items-center justify-center p-4 text-center tracking-wide w-full" role="alert">
61+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
62+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
63+
</svg>
64+
<div class="ms-3 text-sm font-medium">
65+
You are viewing the <a class="font-semibold underline hover:no-underline" href="https://github.com/coq/rocq-prover.org/tree/<%s git_branch %>"><%s git_branch %> branch</a> of the website @
66+
<a class="font-semibold underline hover:no-underline" href="https://github.com/coq/rocq-prover.org/commit/<%s git_commit %>"><%s git_short_commit %></a>,
67+
not the <a class="font-semibold underline hover:no-underline" href="https://rocq-prover.org">live version</a>.
68+
</div>
69+
<button type="button" class="ms-3 -mx-1.5 -my-1.5 bg-red-50 text-red-500 rounded-lg focus:ring-2 focus:ring-red-400 p-1.5 hover:bg-red-200 inline-flex items-center justify-center h-8 w-8 dark:bg-gray-800 dark:text-red-400 dark:hover:bg-gray-700" data-dismiss-target="#alert-border-2" aria-label="Close">
70+
<span class="sr-only">Dismiss</span>
71+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
72+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
73+
</svg>
74+
</button>
75+
</div>
76+
<script src="https://unpkg.com/[email protected]/dist/flowbite.js"></script>
77+
<% ); %>
5578
<nav class="bg-background container-fluid dark:bg-dark-background_navigation flex gap-5 h-20 header items-center justify-between rounded-b-lg shadow-sm wide xl:gap-8">
5679
<ul class="order-0 space space-x-5 xl:space-x-8 items-center flex text-content font-medium dark:text-title dark:text-opacity-60 dark:font-semibold">
5780
<li style="width:170px">
@@ -102,14 +125,13 @@ in
102125
<nav class="z-50 h-full fixed right-0 top-0 max-w-full w-96 bg-background dark:bg-dark-background shadow-lg" x-show="open" x-cloak
103126
@click.away="open = false" x-transition:enter="transition duration-200 ease-out"
104127
x-transition:enter-start="translate-x-full" x-transition:leave="transition duration-100 ease-in"
105-
x-transition:leave-end="translate-x-full">
128+
x-transition:leave-end="translate-x-full">
106129
<ul class="text-content p-6 font-semibold">
107130
<li class="flex justify-between items-center">
108131
<a href="<%s Url.index %>">
109132
<img src="<%s Rocqproverorg_static.Asset.url "logos/logo-rocq-blue_orange.svg" %>" width="132" alt="Rocq logo" class="dark:hidden">
110133
<img src="<%s Rocqproverorg_static.Asset.url "logos/logo-rocq-white.svg" %>" width="132" alt="Rocq logo" class="hidden dark:inline">
111134
</a>
112-
113135
<div class=""
114136
x-on:click="open = false">
115137
<button aria-label="close" class="text-content dark:text-dark-title">
@@ -127,7 +149,6 @@ in
127149
%>
128150
</form>
129151
</li>
130-
131152
<% nav_items |> List.iter (fun (n : nav_item) -> %>
132153
<li><%s! menu_link ~_class:"block" ~active:(active_top_nav_item=Some n) ~href:(url_of_nav_item n) ~title:(string_of_nav_item n) () %></li>
133154
<% ); %>

0 commit comments

Comments
 (0)