Skip to content

Commit c3bd2ab

Browse files
authored
CI updates (#9)
* Adding PR checks * Addressing warning * Adding codeowners * Updating package names * Clean up * Configuring spotless * Spotless * Attaching spotlessApply to compilation * Clean up
1 parent 77f17d1 commit c3bd2ab

File tree

24 files changed

+631
-280
lines changed

24 files changed

+631
-280
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- "**/*.md"
7+
- "**/*.png"
8+
push:
9+
branches:
10+
- main
11+
paths-ignore:
12+
- "**/*.md"
13+
- "**/*.png"
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
checks:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v5
23+
- uses: actions/setup-java@v5
24+
with:
25+
distribution: 'temurin'
26+
java-version: '17'
27+
- name: Checks and unit tests
28+
run: ./checks.sh
29+
- name: Store test results
30+
if: success() || failure()
31+
uses: actions/upload-artifact@v5
32+
with:
33+
name: test-results
34+
path: |
35+
**/build/reports/tests/testDebugUnitTest/**/*
36+
**/build/test-results/testDebug*/TEST-*.xml
37+
**/build/test-results/test/TEST-*.xml
38+
**/build/outputs/androidTest-results/**/TEST-*.xml
39+
40+
# The very last job to report whether the Workflow passed.
41+
# This will act as the Branch Protection gatekeeper
42+
ci:
43+
if: always()
44+
runs-on: ubuntu-latest
45+
needs:
46+
- checks
47+
steps:
48+
- id: check
49+
uses: elastic/oblt-actions/check-dependent-jobs@v1
50+
with:
51+
jobs: ${{ toJSON(needs) }}
52+
- run: ${{ steps.check.outputs.is-success }}
Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package co.elastic.otel.android.demo
220

321
import android.app.Application
@@ -7,22 +25,21 @@ import co.elastic.otel.android.extensions.log
725
import co.elastic.otel.android.extensions.span
826

927
class MyApp : Application() {
10-
companion object {
11-
internal lateinit var agent: ElasticOtelAgent
12-
}
28+
companion object {
29+
internal lateinit var agent: ElasticOtelAgent
30+
}
1331

14-
override fun onCreate() {
15-
super.onCreate()
16-
agent = ElasticApmAgent.builder(this)
32+
override fun onCreate() {
33+
super.onCreate()
34+
agent =
35+
ElasticApmAgent.builder(this)
1736
// For Android Emulators, the "10.0.2.2" address is the one of its host machine.
1837
// Using it here allows accessing services that are running on the host machine from an
1938
// Android application that runs in the emulator.
2039
.setExportUrl("http://10.0.2.2:4318")
2140
.setServiceName("weather-demo-app")
2241
.build()
2342

24-
agent.span("Creating app") {
25-
agent.log("During app creation")
26-
}
27-
}
28-
}
43+
agent.span("Creating app") { agent.log("During app creation") }
44+
}
45+
}
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package co.elastic.otel.android.demo.network
220

321
import co.elastic.otel.android.demo.network.data.ForecastResponse
422
import retrofit2.http.GET
523
import retrofit2.http.Query
624

725
interface CityWeatherService {
8-
@GET("forecast")
9-
suspend fun getCurrentWeather(
10-
@Query("city") city: String
11-
): ForecastResponse
12-
}
26+
@GET("forecast") suspend fun getCurrentWeather(@Query("city") city: String): ForecastResponse
27+
}
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package co.elastic.otel.android.demo.network
220

321
import co.elastic.otel.android.demo.network.data.ForecastResponse
@@ -6,18 +24,19 @@ import retrofit2.converter.gson.GsonConverterFactory
624

725
object WeatherRestManager {
826

9-
private val service: CityWeatherService by lazy {
10-
val retrofit = Retrofit.Builder()
27+
private val service: CityWeatherService by lazy {
28+
val retrofit =
29+
Retrofit.Builder()
1130
// For Android Emulators, the "10.0.2.2" address is the one of its host machine.
1231
// Using it here allows accessing services that are running on the host machine from an
1332
// Android application that runs in the emulator.
1433
.baseUrl("http://10.0.2.2:8080/v1/")
1534
.addConverterFactory(GsonConverterFactory.create())
1635
.build()
17-
retrofit.create(CityWeatherService::class.java)
18-
}
36+
retrofit.create(CityWeatherService::class.java)
37+
}
1938

20-
suspend fun getCurrentCityWeather(city: String): ForecastResponse {
21-
return service.getCurrentWeather(city)
22-
}
23-
}
39+
suspend fun getCurrentCityWeather(city: String): ForecastResponse {
40+
return service.getCurrentWeather(city)
41+
}
42+
}
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package co.elastic.otel.android.demo.network.data
220

3-
data class CurrentWeatherResponse(val temperature: Double)
21+
data class CurrentWeatherResponse(val temperature: Double)
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package co.elastic.otel.android.demo.network.data
220

321
import com.google.gson.annotations.SerializedName
422

523
data class ForecastResponse(
6-
@SerializedName("current_weather")
7-
val currentWeather: CurrentWeatherResponse
8-
)
24+
@SerializedName("current_weather") val currentWeather: CurrentWeatherResponse
25+
)
Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package co.elastic.otel.android.demo.ui
220

321
import android.os.Bundle
@@ -13,45 +31,46 @@ import co.elastic.otel.android.demo.databinding.FragmentFirstBinding
1331

1432
class FirstFragment : Fragment() {
1533

16-
private var _binding: FragmentFirstBinding? = null
17-
private val binding get() = _binding!!
34+
private var _binding: FragmentFirstBinding? = null
35+
private val binding
36+
get() = _binding!!
1837

19-
override fun onCreateView(
20-
inflater: LayoutInflater, container: ViewGroup?,
21-
savedInstanceState: Bundle?
22-
): View {
23-
_binding = FragmentFirstBinding.inflate(inflater, container, false)
24-
return binding.root
25-
}
38+
override fun onCreateView(
39+
inflater: LayoutInflater,
40+
container: ViewGroup?,
41+
savedInstanceState: Bundle?,
42+
): View {
43+
_binding = FragmentFirstBinding.inflate(inflater, container, false)
44+
return binding.root
45+
}
2646

27-
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
28-
super.onViewCreated(view, savedInstanceState)
47+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
48+
super.onViewCreated(view, savedInstanceState)
2949

30-
binding.buttonFirst.setOnClickListener {
31-
val bundle = bundleOf("city" to binding.citySpinner.selectedItem.toString())
32-
findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment, bundle)
33-
}
50+
binding.buttonFirst.setOnClickListener {
51+
val bundle = bundleOf("city" to binding.citySpinner.selectedItem.toString())
52+
findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment, bundle)
53+
}
3454

35-
binding.buttonCrash.setOnClickListener {
36-
doCrash()
37-
}
55+
binding.buttonCrash.setOnClickListener { doCrash() }
3856

39-
ArrayAdapter.createFromResource(
57+
ArrayAdapter.createFromResource(
4058
view.context,
4159
R.array.city_array,
42-
android.R.layout.simple_spinner_item
43-
).also { adapter ->
44-
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
45-
binding.citySpinner.adapter = adapter
60+
android.R.layout.simple_spinner_item,
61+
)
62+
.also { adapter ->
63+
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
64+
binding.citySpinner.adapter = adapter
4665
}
47-
}
66+
}
4867

49-
private fun doCrash() {
50-
throw RuntimeException("Some crash")
51-
}
68+
private fun doCrash() {
69+
throw RuntimeException("Some crash")
70+
}
5271

53-
override fun onDestroyView() {
54-
super.onDestroyView()
55-
_binding = null
56-
}
57-
}
72+
override fun onDestroyView() {
73+
super.onDestroyView()
74+
_binding = null
75+
}
76+
}

0 commit comments

Comments
 (0)