-
Notifications
You must be signed in to change notification settings - Fork 21
153 lines (133 loc) · 5.03 KB
/
ci.yml
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
146
147
148
149
150
151
152
153
name: Scala Course CI
on:
push:
tags: '*'
paths-ignore:
- 'README.md'
- '**/README.md'
- 'slides/**'
- 'scripts/**'
branches: [ main ]
pull_request:
paths-ignore:
- 'README.md'
- '**/README.md'
- 'slides/**'
- 'scripts/**'
branches: [ main ]
workflow_dispatch:
permissions:
contents: write
env:
EXERCISES_DIRECTORY: ./exercises
jobs:
list-exercises:
runs-on: ubuntu-latest
outputs:
exercises: ${{steps.list.outputs.exercises}}
steps:
- uses: actions/checkout@v3
- id: list
run: echo "::set-output name=exercises::$(ls $EXERCISES_DIRECTORY | grep exercise_ | jq -cnR '[inputs | select(length>0)]')"
# run: echo "name=exercises::$(ls $EXERCISES_DIRECTORY | grep exercise_ | jq -cnR '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT
validate_course:
runs-on: ubuntu-latest
needs: list-exercises
strategy:
fail-fast: false
matrix:
exercise: ${{fromJson(needs.list-exercises.outputs.exercises)}}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
cache: 'sbt'
distribution: 'temurin'
- name: Check code formatting
run: sbt scalafmtCheckAll
working-directory: ${{env.EXERCISES_DIRECTORY}}/${{matrix.exercise}}
- name: Test with sbt
run: sbt test
working-directory: ${{env.EXERCISES_DIRECTORY}}/${{matrix.exercise}}
validate_course_summary:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: validate_course
steps:
- name: Check build matrix status
if: ${{ needs.validate_course.result != 'success' }}
run: exit 1
create_release:
runs-on: ubuntu-latest
needs: [validate_course]
# Release gets triggered only on creating new tags
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- name: Checkout Course Repo
uses: actions/checkout@v3
with:
path: lunatech-scala-2-to-scala3-course
fetch-depth: 0
- name: Setup Course Management Tools
uses: robinraju/[email protected]
with:
repository: lunatech-labs/course-management-tools
tag: "2.0.0-RC6"
fileName: "course-management-tools.zip"
out-file-path: "."
- run: |
unzip course-management-tools.zip
echo "$GITHUB_WORKSPACE/course-management-tools/bin" >> $GITHUB_PATH
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
- name: Setup Coursier Cache
uses: coursier/[email protected]
with:
root: "lunatech-scala-2-to-scala3-course"
- name: Studentify Repo
run: |
mkdir -p studentified
export PATH=${PATH}:$GITHUB_WORKSPACE/CMT/bin
git config --global user.email "[email protected]"
git config --global user.name "Lunatech Labs"
cmta studentify -f -g -m lunatech-scala-2-to-scala3-course -d studentified
(cd studentified && exec zip -r lunatech-scala-2-to-scala3-course-student.zip lunatech-scala-2-to-scala3-course)
- name: Linearize Repo
run: |
mkdir -p linearized
cmta linearize -f -m lunatech-scala-2-to-scala3-course -d linearized
mv linearized/lunatech-scala-2-to-scala3-course linearized/lunatech-scala-2-to-scala3-course-linearized
(cd linearized && exec zip -r lunatech-scala-2-to-scala3-course-linearized.zip lunatech-scala-2-to-scala3-course-linearized)
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Studentified repo to Github release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # release created from previous step
asset_path: ./studentified/lunatech-scala-2-to-scala3-course-student.zip
asset_name: lunatech-scala-2-to-scala3-course-student.zip
asset_content_type: application/zip
- name: Upload Linearized repo to Github release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # release created from previous step
asset_path: ./linearized/lunatech-scala-2-to-scala3-course-linearized.zip
asset_name: lunatech-scala-2-to-scala3-course-linearized.zip
asset_content_type: application/zip