| 1 | name: CI (Coq, timing-diff, docker, dev) |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | build_target: |
| 7 | description: 'Build target for timing diff' |
| 8 | required: false |
| 9 | default: 'standalone-ocaml lite-generated-files' |
| 10 | type: string |
| 11 | target_repository: |
| 12 | description: 'Target repository to checkout (e.g., username/repo)' |
| 13 | required: false |
| 14 | default: '' |
| 15 | type: string |
| 16 | target_branch: |
| 17 | description: 'Target branch to checkout' |
| 18 | required: true |
| 19 | type: string |
| 20 | |
| 21 | jobs: |
| 22 | build: |
| 23 | strategy: |
| 24 | fail-fast: false |
| 25 | matrix: |
| 26 | include: |
| 27 | - env: { COQ_VERSION: "master", DOCKER_COQ_VERSION: "dev", DOCKER_OCAML_VERSION: "default", SKIP_VALIDATE: "" , COQCHKEXTRAFLAGS: "-bytecode-compiler yes", EXTRA_GH_REPORTIFY: "--warnings", ALLOW_DIFF: "1", CI: "1" } |
| 28 | os: 'ubuntu-latest' |
| 29 | |
| 30 | runs-on: ${{ matrix.os }} |
| 31 | env: ${{ matrix.env }} |
| 32 | name: docker-${{ matrix.env.COQ_VERSION }} |
| 33 | |
| 34 | concurrency: |
| 35 | group: ${{ github.workflow }}-${{ matrix.env.COQ_VERSION }}-${{ github.event.inputs.target_repository || github.repository }}-${{ github.event.inputs.target_branch || github.ref }}-${{ github.event.inputs.build_target }}${{ github.head_ref || github.run_id }} |
| 36 | cancel-in-progress: true |
| 37 | |
| 38 | steps: |
| 39 | - name: record inputs to summary |
| 40 | run: | |
| 41 | printf "%s@%s make %s\n\n" "${{ github.event.inputs.target_repository || github.repository }}" "${{ github.event.inputs.target_branch || github.ref }}" "${{ github.event.inputs.build_target }}" |
| 42 | printf "%s@%s make %s\n\n" "${{ github.event.inputs.target_repository || github.repository }}" "${{ github.event.inputs.target_branch || github.ref }}" "${{ github.event.inputs.build_target }}" >> $GITHUB_STEP_SUMMARY |
| 43 | - uses: actions/checkout@v4 |
| 44 | with: |
| 45 | submodules: recursive |
| 46 | - name: echo host build params |
| 47 | run: etc/ci/describe-system-config.sh |
| 48 | - name: echo container build params |
| 49 | uses: coq-community/docker-coq-action@v1 |
| 50 | with: |
| 51 | coq_version: ${{ matrix.env.DOCKER_COQ_VERSION }} |
| 52 | ocaml_version: ${{ matrix.env.DOCKER_OCAML_VERSION }} |
| 53 | export: CI ALLOW_DIFF COQCHKEXTRAFLAGS GITHUB_STEP_SUMMARY |
| 54 | custom_script: | |
| 55 | eval $(opam env) |
| 56 | etc/ci/describe-system-config.sh |
| 57 | - name: compute base sha and current branch |
| 58 | id: git_ids |
| 59 | env: |
| 60 | GH_TOKEN: ${{ github.token }} |
| 61 | run: | |
| 62 | # Get the current branch name |
| 63 | CURRENT_BRANCH=${{ github.event.inputs.target_branch }} |
| 64 | echo "Current branch: $CURRENT_BRANCH" |
| 65 | |
| 66 | # Check if this is a PR |
| 67 | # Check if this branch has an associated PR |
| 68 | PR_NUMBER=$(gh pr list --repo mit-plv/fiat-crypto --head $CURRENT_BRANCH --json number --jq '.[0].number') |
| 69 | # Add remote for target repository if specified |
| 70 | if [[ -n "${{ github.event.inputs.target_repository }}" && "${{ github.event.inputs.target_repository }}" != "${{ github.repository }}" ]]; then |
| 71 | echo "Adding remote for target repository: ${{ github.event.inputs.target_repository }}" |
| 72 | git remote add target_repo "https://github.com/${{ github.event.inputs.target_repository }}.git" |
| 73 | git fetch target_repo $CURRENT_BRANCH || true |
| 74 | git checkout -b $CURRENT_BRANCH target_repo/$CURRENT_BRANCH |
| 75 | else |
| 76 | git fetch origin $CURRENT_BRANCH || true |
| 77 | git checkout -b $CURRENT_BRANCH origin/$CURRENT_BRANCH |
| 78 | fi |
| 79 | if [[ -n "$PR_NUMBER" ]]; then |
| 80 | # Get the base branch from the PR |
| 81 | BASE_BRANCH=$(gh pr view $PR_NUMBER --json baseRefName --jq '.baseRefName') |
| 82 | echo "This branch has PR #$PR_NUMBER from $CURRENT_BRANCH to $BASE_BRANCH" |
| 83 | # Get the merge-base of the base branch and current commit |
| 84 | git fetch origin $BASE_BRANCH || true |
| 85 | BASE_SHA=$(git merge-base target_repo/$BASE_BRANCH $CURRENT_BRANCH) |
| 86 | |
| 87 | else |
| 88 | # For non-PRs, use merge-base of current branch and master as base_sha |
| 89 | echo "This is not a PR, using merge-base with master" |
| 90 | git fetch origin master || true |
| 91 | BASE_SHA=$(git merge-base master $CURRENT_BRANCH) |
| 92 | fi |
| 93 | |
| 94 | echo "Using base SHA: $BASE_SHA" |
| 95 | git log --oneline $BASE_SHA..$CURRENT_BRANCH |
| 96 | |
| 97 | echo "base_sha=${BASE_SHA}" >> $GITHUB_OUTPUT |
| 98 | echo "current_branch=${CURRENT_BRANCH}" >> $GITHUB_OUTPUT |
| 99 | - name: deps |
| 100 | uses: coq-community/docker-coq-action@v1 |
| 101 | with: |
| 102 | coq_version: ${{ matrix.env.DOCKER_COQ_VERSION }} |
| 103 | ocaml_version: ${{ matrix.env.DOCKER_OCAML_VERSION }} |
| 104 | export: CI ALLOW_DIFF COQCHKEXTRAFLAGS GITHUB_STEP_SUMMARY |
| 105 | custom_script: etc/ci/github-actions-docker-make.sh COQBIN="$(dirname "$(which coqc)")/" -j2 deps |
| 106 | - name: all-except-generated-and-js-of-ocaml |
| 107 | uses: coq-community/docker-coq-action@v1 |
| 108 | with: |
| 109 | coq_version: ${{ matrix.env.DOCKER_COQ_VERSION }} |
| 110 | ocaml_version: ${{ matrix.env.DOCKER_OCAML_VERSION }} |
| 111 | export: CI ALLOW_DIFF COQCHKEXTRAFLAGS GITHUB_STEP_SUMMARY |
| 112 | custom_script: etc/ci/github-actions-docker-make.sh ${EXTRA_GH_REPORTIFY} -j2 all-except-generated-and-js-of-ocaml |
| 113 | - name: pre-standalone-extracted |
| 114 | uses: coq-community/docker-coq-action@v1 |
| 115 | with: |
| 116 | coq_version: ${{ matrix.env.DOCKER_COQ_VERSION }} |
| 117 | ocaml_version: ${{ matrix.env.DOCKER_OCAML_VERSION }} |
| 118 | export: CI ALLOW_DIFF COQCHKEXTRAFLAGS GITHUB_STEP_SUMMARY |
| 119 | custom_script: etc/ci/github-actions-docker-make.sh ${EXTRA_GH_REPORTIFY} -j2 pre-standalone-extracted |
| 120 | - name: run timing diff |
| 121 | uses: coq-community/docker-coq-action@v1 |
| 122 | with: |
| 123 | coq_version: ${{ matrix.env.DOCKER_COQ_VERSION }} |
| 124 | ocaml_version: ${{ matrix.env.DOCKER_OCAML_VERSION }} |
| 125 | export: CI ALLOW_DIFF COQCHKEXTRAFLAGS GITHUB_STEP_SUMMARY |
| 126 | custom_script: | |
| 127 | BASE_SHA=${{ steps.git_ids.outputs.base_sha }} |
| 128 | CURRENT_BRANCH=${{ steps.git_ids.outputs.current_branch }} |
| 129 | |
| 130 | # Run the timing diff script |
| 131 | eval $(opam env) |
| 132 | etc/coq-scripts/timing/make-pretty-timed-diff-branch.sh "$BASE_SHA" "$CURRENT_BRANCH" ${{ github.event.inputs.build_target }} |
| 133 | |
| 134 | - name: Display commits between base and current |
| 135 | run: | |
| 136 | BASE_SHA=${{ steps.git_ids.outputs.base_sha }} |
| 137 | CURRENT_BRANCH=${{ steps.git_ids.outputs.current_branch }} |
| 138 | |
| 139 | echo "### Commits between base and current branch" >> $GITHUB_STEP_SUMMARY |
| 140 | echo "" >> $GITHUB_STEP_SUMMARY |
| 141 | |
| 142 | # Get each commit hash between base and current branch |
| 143 | COMMIT_HASHES=$(git log --pretty=format:"%H" $BASE_SHA..$CURRENT_BRANCH) |
| 144 | |
| 145 | # For each commit, create a separate details/summary section |
| 146 | for COMMIT in $COMMIT_HASHES; do |
| 147 | # Get commit details |
| 148 | COMMIT_SHORT=$(git log -1 --pretty=format:"%h" $COMMIT) |
| 149 | COMMIT_SUBJECT=$(git log -1 --pretty=format:"%s" $COMMIT) |
| 150 | COMMIT_FULL=$(git log -1 --pretty=format:"%B" $COMMIT) |
| 151 | |
| 152 | # Add to step summary - just oneline in summary |
| 153 | printf "<details>\n" >> $GITHUB_STEP_SUMMARY |
| 154 | printf "<summary>%s: %s</summary>\n" "$COMMIT_SHORT" "$COMMIT_SUBJECT" >> $GITHUB_STEP_SUMMARY |
| 155 | printf "\n" >> $GITHUB_STEP_SUMMARY |
| 156 | # printf "```\n" >> $GITHUB_STEP_SUMMARY |
| 157 | printf "%s\n" "$COMMIT_FULL" >> $GITHUB_STEP_SUMMARY |
| 158 | # printf "```\n" >> $GITHUB_STEP_SUMMARY |
| 159 | printf "</details>\n" >> $GITHUB_STEP_SUMMARY |
| 160 | printf "\n" >> $GITHUB_STEP_SUMMARY |
| 161 | |
| 162 | # Output to GitHub Actions log with groups - oneline in group name |
| 163 | printf "::group::%s: %s\n" "$COMMIT_SHORT" "$COMMIT_SUBJECT" |
| 164 | git log -1 --pretty=fuller $COMMIT |
| 165 | printf "::endgroup::\n" |
| 166 | done |