-
Notifications
You must be signed in to change notification settings - Fork 13
145 lines (120 loc) · 4.95 KB
/
PRformat.yml
File metadata and controls
145 lines (120 loc) · 4.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Build PR (only formatting)
on:
pull_request:
branches:
- 'master'
env:
OPAMROOT: /home/opam/.opam
OPAMCONFIRMLEVEL: unsafe-yes
jobs:
build:
runs-on: ubuntu-latest
container:
image: kakadu18/ocaml:comp25
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: sudo apt update
- name: List installed OPAM packages
run: opam list
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
############# Detecting and compiling fp2024
# Smart link about setting environment variables
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Detect latest changes in ${{ github.event.repository.name }}
working-directory: .github
run: |
printf '%s\n%s\n' '#require "str,unix";;' "$(cat detect_latest_pr.ml)" > detect_latest_pr.ml
printf '%s\n%s\n' '#use "topfind";;' "$(cat detect_latest_pr.ml)" > detect_latest_pr.ml
(cd .. && opam exec -- ocaml .github/detect_latest_pr.ml -master -repo ${{ github.event.repository.name }} -template demo) >> $GITHUB_ENV
- name: Detected directory -- ${{ env.latest }}
run: echo ${{ env.latest }}
- name: Naive linting
run: |
cd ${{ env.latest }}
python ../.github/lint_filesystem.py ${{ env.latest }}
# - name: Checking ocamlformat
# id: check-ocamlformat
# continue-on-error: true
# run: |
# echo "PROPERLY_FORMATTED=y" >> $GITHUB_ENV
# cd ${{ env.latest }} && opam exec -- dune build @fmt --profile=release || echo "PROPERLY_FORMATTED=n" >> $GITHUB_ENV
# We need to install dependencies because repo could have weird version of ocamlformat
- name: Look for `rust-toolchain.toml`
run: |
cd ${{ env.latest }}
RUST_TOOLCHAIN=$(find . -name "rust-toolchain.toml" | head -n 1)
if [ -n "$RUST_TOOLCHAIN" ]; then
echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> "$GITHUB_ENV"
echo "RUST_ROOT=$(dirname "$RUST_TOOLCHAIN")" >> "$GITHUB_ENV"
fi
- name: Install rustup
if: ${{ env.RUST_TOOLCHAIN != '' }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y && . "$HOME/.cargo/env"
rustup --version
echo "CARGO_HOME=$HOME/.cargo" >> $GITHUB_ENV
echo "RUSTUP_HOME=$HOME/.rustup" >> $GITHUB_ENV
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV
- name: Setup Rust
if: ${{ env.RUST_TOOLCHAIN != '' }}
run: |
cd ${{ env.latest }}
cd ${{ env.RUST_ROOT }}
rustup show
- name: Installing dependencies for ${{ env.latest }}...
run: |
opam update
cd ./${{ env.latest }}
opam install . --depext-only --with-test --with-doc
opam install . --deps-only --with-test --with-doc
- name: Run `cargo fmt`
if: ${{ env.RUST_TOOLCHAIN != '' }}
run: |
cd ${{ env.latest }}
cd ${{ env.RUST_ROOT }}
cargo fmt --check
- name: Run `clippy`
if: ${{ env.RUST_TOOLCHAIN != '' }}
run: |
cd ${{ env.latest }}
cd ${{ env.RUST_ROOT }}
cargo clippy -- -D warnings
- name: Checking ocamlformat
run: |
cd ${{ env.latest }}
opam exec -- dune build @fmt --profile=release
# TODO: onfail post a comment how to fix it
# - name: Find a comment with OCamlformat report
# uses: peter-evans/find-comment@v2
# id: fc
# with:
# issue-number: ${{ github.event.number }}
# body-includes: OCamlformat report for
# comment-author: github-actions[bot]
# - name: Remove comment if build is OK and a comment was found
# if: steps.fc.outputs.comment-id != 0
# run: |
# curl -L https://api.github.com/repos/Kakadu/fp2024/pulls/comments/${{ steps.fc.outputs.comment-id }} \
# -X DELETE -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
# -H "X-GitHub-Api-Version: 2022-11-28"
# TODO: move to workflow with proper authorization
#- name: Create comment
# if: ${{ env.PROPERLY_FORMATTED == 'n' }}
# uses: peter-evans/create-or-update-comment@v1
# with:
# edit-mode: replace
# issue-number: ${{ github.event.number }}
# body: |
# ### OCamlformat report for ${{ env.latest }}
# Format check failed. It could have two reasons:
# * You didn't configure VsCode extensions properly
# * The versions of ocamlformat differ on your machine and on CI