forked from AY2425S2-CS2113-W13-1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (92 loc) · 3.29 KB
/
Copy pathFormatLintTestBuild.yml
File metadata and controls
110 lines (92 loc) · 3.29 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
name: Auto Java Formatter
on: push
permissions:
contents: write
jobs:
lint:
name: Lint Code Base
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout latest code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Detect and pull latest changes from the same branch
run: |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH_NAME"
git fetch origin $BRANCH_NAME # Fetch the latest changes from the current branch
git reset --hard origin/$BRANCH_NAME # Ensure we are using the latest commit from the branch
git log -1 # Show latest commit for debugging
- name: Lint Code Base
uses: github/super-linter@v4
env:
RUN-LOCAL: false
LINTER_RULES_PATH: config/checkstyle
JAVA_FILE_NAME: ../../config/checkstyle/checkstyle.xml
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVA: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
name: Run Tests with Gradle
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout latest code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Detect and pull latest changes from the same branch
run: |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH_NAME"
git fetch origin $BRANCH_NAME # Fetch the latest changes from the current branch
git reset --hard origin/$BRANCH_NAME # Ensure we are using the latest commit from the branch
git log -1 # Show latest commit for debugging
- name: Setup JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'
distribution: 'jdk+fx'
- name: Grant execute permission for Gradle
run: chmod +x gradlew
- name: Run Gradle Tests
run: ./gradlew test
build:
name: Build & Upload JAR
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout latest code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Detect and pull latest changes from the same branch
run: |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH_NAME"
git fetch origin $BRANCH_NAME # Fetch the latest changes from the current branch
git reset --hard origin/$BRANCH_NAME # Ensure we are using the latest commit from the branch
git log -1 # Show latest commit for debugging
- name: Setup JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'
distribution: 'jdk+fx'
- name: Grant execute permission for Gradle
run: chmod +x gradlew
- name: Build JAR without Checkstyle
run: ./gradlew build -x checkstyleMain -x checkstyleTest
- name: Find JAR File
run: |
JAR_PATH=$(find build/libs -name "*.jar" | head -n 1)
echo "JAR_PATH=$JAR_PATH" >> $GITHUB_ENV
- name: Upload JAR as an Artifact
uses: actions/upload-artifact@v4
with:
name: javatro-jar
path: ${{ env.JAR_PATH }}