-
Notifications
You must be signed in to change notification settings - Fork 12
132 lines (109 loc) · 4.27 KB
/
Copy pathcopilot-setup-steps.yml
File metadata and controls
132 lines (109 loc) · 4.27 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
name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed
# Allows for streamlined validation,
# and allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
env:
CLAVA_BRANCH: ${{ github.head_ref || github.ref_name }}
jobs:
# The job MUST be called `copilot-setup-steps`
# otherwise it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
# Permissions set just for the setup steps
# Copilot has permissions to its branch
permissions:
# To allow us to clone the repo for setup
contents: read
# The setup steps - install our dependencies
steps:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current
dependency-graph: generate-and-submit
- name: Checkout clava
uses: actions/checkout@v6
with:
path: clava
- name: Determine repository refs
id: repo-refs
shell: bash
env:
BRANCH_NAME: ${{ env.CLAVA_BRANCH }}
run: |
set -euo pipefail
determine_ref() {
local prefix=$1
local repo=$2
local url="https://github.com/${repo}.git"
local default_branch
default_branch=$(git ls-remote --symref "$url" HEAD | awk '/^ref:/ {print $2}' | sed 's@refs/heads/@@')
echo "${prefix}_default=${default_branch}" >> "$GITHUB_OUTPUT"
echo "Default branch for ${repo} is '${default_branch}'"
if git ls-remote --heads "$url" "refs/heads/${BRANCH_NAME}" >/dev/null; then
echo "${prefix}_match=true" >> "$GITHUB_OUTPUT"
echo "${prefix}_ref=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
echo "Branch '${BRANCH_NAME}' exists in ${repo}"
else
echo "${prefix}_match=false" >> "$GITHUB_OUTPUT"
echo "${prefix}_ref=${default_branch}" >> "$GITHUB_OUTPUT"
echo "Branch '${BRANCH_NAME}' not found in ${repo}. Falling back to '${default_branch}'."
fi
}
determine_ref "lara" "specs-feup/lara-framework"
determine_ref "specs" "specs-feup/specs-java-libs"
- name: Echo checks
run: |
echo "Clava branch: ${{ env.CLAVA_BRANCH }}"
echo "Matching branch found (lara-framework): ${{ steps.repo-refs.outputs.lara_match }}"
echo "Matching branch found (specs-java-libs): ${{ steps.repo-refs.outputs.specs_match }}"
echo "Lara framework ref: ${{ steps.repo-refs.outputs.lara_ref }}"
echo "Specs-java-libs ref: ${{ steps.repo-refs.outputs.specs_ref }}"
echo "Lara framework default fallback: ${{ steps.repo-refs.outputs.lara_default }}"
echo "Specs-java-libs default fallback: ${{ steps.repo-refs.outputs.specs_default }}"
echo "Pull request base_ref (if any): ${{ github.base_ref }}"
- name: Checkout lara-framework
uses: actions/checkout@v6
with:
repository: specs-feup/lara-framework
path: lara-framework
ref: ${{ steps.repo-refs.outputs.lara_ref }}
- name: Checkout specs-java-libs
uses: actions/checkout@v6
with:
repository: specs-feup/specs-java-libs
path: specs-java-libs
ref: ${{ steps.repo-refs.outputs.specs_ref }}
- name: Build Weaver
run: |
cd clava/ClavaWeaver
gradle installDist
- name: Setup java-binaries symlink
run: |
cd clava/Clava-JS
ln -s ../ClavaWeaver/build/install/ClavaWeaver/ java-binaries
- name: Setup JS workspace
run: |
echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "clava/Clava-JS", "lara-framework/Lara-JS" ] }' > package.json
npm install
- name: Build Lara-JS
run: |
cd lara-framework/Lara-JS
npm run build
- name: Build Clava-JS
run: |
cd clava/Clava-JS
npm run build