Skip to content

Commit 4aaac2b

Browse files
committed
Add CI workflow
1 parent ab6a5dc commit 4aaac2b

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

.github/workflows/ci.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Scala Course CI
2+
3+
on:
4+
push:
5+
tags: '*'
6+
paths-ignore:
7+
- 'README.md'
8+
- '**/README.md'
9+
- 'slides/**'
10+
- 'scripts/**'
11+
branches: [ main ]
12+
pull_request:
13+
paths-ignore:
14+
- 'README.md'
15+
- '**/README.md'
16+
- 'slides/**'
17+
- 'scripts/**'
18+
branches: [ main ]
19+
20+
workflow_dispatch:
21+
22+
permissions:
23+
contents: write
24+
25+
env:
26+
EXERCISES_DIRECTORY: ./exercises
27+
28+
jobs:
29+
list-exercises:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
exercises: ${{steps.list.outputs.exercises}}
33+
steps:
34+
- uses: actions/checkout@v3
35+
- id: list
36+
run: echo "::set-output name=exercises::$(ls $EXERCISES_DIRECTORY | grep exercise_ | jq -cnR '[inputs | select(length>0)]')"
37+
# run: echo "name=exercises::$(ls $EXERCISES_DIRECTORY | grep exercise_ | jq -cnR '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT
38+
39+
validate_course:
40+
runs-on: ubuntu-latest
41+
needs: list-exercises
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
exercise: ${{fromJson(needs.list-exercises.outputs.exercises)}}
46+
steps:
47+
- uses: actions/checkout@v3
48+
- name: Set up JDK 11
49+
uses: actions/setup-java@v3
50+
with:
51+
java-version: 11
52+
cache: 'sbt'
53+
distribution: 'temurin'
54+
55+
- name: Test with sbt
56+
run: sbt 'set scalaVersion := "3.0.0"' test
57+
working-directory: ${{env.EXERCISES_DIRECTORY}}/${{matrix.exercise}}
58+
59+
validate_course_summary:
60+
if: ${{ always() }}
61+
runs-on: ubuntu-latest
62+
needs: validate_course
63+
steps:
64+
- name: Check build matrix status
65+
if: ${{ needs.validate_course.result != 'success' }}
66+
run: exit 1
67+
68+
create_release:
69+
runs-on: ubuntu-latest
70+
needs: [validate_course]
71+
# Release gets triggered only on creating new tags
72+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
73+
74+
steps:
75+
76+
- name: Checkout Course Repo
77+
uses: actions/checkout@v3
78+
with:
79+
path: lunatech-scala-2-to-scala3-course
80+
fetch-depth: 0
81+
82+
- name: Setup Course Management Tools
83+
uses: robinraju/[email protected]
84+
with:
85+
repository: lunatech-labs/course-management-tools
86+
tag: "2.0.0-RC6"
87+
fileName: "course-management-tools.zip"
88+
out-file-path: "."
89+
- run: |
90+
unzip course-management-tools.zip
91+
echo "$GITHUB_WORKSPACE/course-management-tools/bin" >> $GITHUB_PATH
92+
93+
- name: Set up JDK 11
94+
uses: actions/setup-java@v3
95+
with:
96+
java-version: 11
97+
distribution: 'temurin'
98+
99+
- name: Setup Coursier Cache
100+
uses: coursier/[email protected]
101+
with:
102+
root: "lunatech-scala-2-to-scala3-course"
103+
104+
- name: Studentify Repo
105+
run: |
106+
mkdir -p studentified
107+
export PATH=${PATH}:$GITHUB_WORKSPACE/CMT/bin
108+
git config --global user.email "[email protected]"
109+
git config --global user.name "Lunatech Labs"
110+
cmta studentify -f -g -m lunatech-scala-2-to-scala3-course -d studentified
111+
(cd studentified && exec zip -r lunatech-scala-2-to-scala3-course-student.zip lunatech-scala-2-to-scala3-course)
112+
113+
- name: Linearize Repo
114+
run: |
115+
mkdir -p linearized
116+
cmta linearize -f -m lunatech-scala-2-to-scala3-course -d linearized
117+
mv linearized/lunatech-scala-2-to-scala3-course linearized/lunatech-scala-2-to-scala3-course-linearized
118+
(cd linearized && exec zip -r lunatech-scala-2-to-scala3-course-linearized.zip lunatech-scala-2-to-scala3-course-linearized)
119+
120+
- name: Create Github Release
121+
id: create_release
122+
uses: actions/create-release@v1
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
125+
with:
126+
tag_name: ${{ github.ref }}
127+
release_name: Release ${{ github.ref }}
128+
draft: false
129+
prerelease: false
130+
131+
- name: Upload Studentified repo to Github release
132+
uses: actions/upload-release-asset@v1
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
with:
136+
upload_url: ${{ steps.create_release.outputs.upload_url }} # release created from previous step
137+
asset_path: ./studentified/lunatech-scala-2-to-scala3-course-student.zip
138+
asset_name: lunatech-scala-2-to-scala3-course-student.zip
139+
asset_content_type: application/zip
140+
141+
- name: Upload Linearized repo to Github release
142+
uses: actions/upload-release-asset@v1
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
with:
146+
upload_url: ${{ steps.create_release.outputs.upload_url }} # release created from previous step
147+
asset_path: ./linearized/lunatech-scala-2-to-scala3-course-linearized.zip
148+
asset_name: lunatech-scala-2-to-scala3-course-linearized.zip
149+
asset_content_type: application/zip

0 commit comments

Comments
 (0)