Skip to content

Commit

Permalink
build: workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-chekyrta committed Oct 31, 2024
1 parent 1bc7af4 commit 6f26f85
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/add-depr-ticket-to-depr-board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Run the workflow that adds new tickets that are either:
# - labelled "DEPR"
# - title starts with "[DEPR]"
# - body starts with "Proposal Date" (this is the first template field)
# to the org-wide DEPR project board

name: Add newly created DEPR issues to the DEPR project board

on:
issues:
types: [opened]

jobs:
routeissue:
uses: openedx/.github/.github/workflows/add-depr-ticket-to-depr-board.yml@master
secrets:
GITHUB_APP_ID: ${{ secrets.GRAPHQL_AUTH_APP_ID }}
GITHUB_APP_PRIVATE_KEY: ${{ secrets.GRAPHQL_AUTH_APP_PEM }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_ISSUE_BOT_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/add-remove-label-on-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This workflow runs when a comment is made on the ticket
# If the comment starts with "label: " it tries to apply
# the label indicated in rest of comment.
# If the comment starts with "remove label: ", it tries
# to remove the indicated label.
# Note: Labels are allowed to have spaces and this script does
# not parse spaces (as often a space is legitimate), so the command
# "label: really long lots of words label" will apply the
# label "really long lots of words label"

name: Allows for the adding and removing of labels via comment

on:
issue_comment:
types: [created]

jobs:
add_remove_labels:
uses: openedx/.github/.github/workflows/add-remove-label-on-comment.yml@master

10 changes: 10 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Run commitlint on the commit messages in a pull request.

name: Lint Commit Messages

on:
- pull_request

jobs:
commitlint:
uses: openedx/.github/.github/workflows/commitlint.yml@master
12 changes: 12 additions & 0 deletions .github/workflows/self-assign-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This workflow runs when a comment is made on the ticket
# If the comment starts with "assign me" it assigns the author to the
# ticket (case insensitive)

name: Assign comment author to ticket if they say "assign me"
on:
issue_comment:
types: [created]

jobs:
self_assign_by_comment:
uses: openedx/.github/.github/workflows/self-assign-issue.yml@master
33 changes: 33 additions & 0 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: SwiftLint

on:
workflow_dispatch:

pull_request:

jobs:
lint:
name: SwiftLint
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Setup
run:
xcodes select 16.1

- name: SwiftLint
run:
swift package plugin --allow-writing-to-package-directory swiftlint --reporter sarif --output swiftlint.report.sarif

- name: Prepare swiftlint.report.sarif
if: success() || failure()
run:
swift PrepareSarifToUpload.swift

- name: Upload report
uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: swiftlint.report.sarif
22 changes: 22 additions & 0 deletions .github/workflows/xcodebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: XCodeBuild

on:
workflow_dispatch:

pull_request:

jobs:
build:
name: Build
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Setup
run:
xcodes select 16.1

- name: Build
run:
xcodebuild -scheme OEXFirebaseAnalytics -destination 'platform=iOS Simulator,name=iPhone SE (3rd generation)' -skipPackagePluginValidation -skipMacroValidation build
54 changes: 54 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
warning_threshold: 1
disabled_rules: # rule identifiers to exclude from running
- identifier_name
- comment_spacing
- force_cast
- empty_count
- nesting
- cyclomatic_complexity
- multiple_closures_with_trailing_closure
# - colon
# - comma
# - control_statement
opt_in_rules: # some rules are only opt-in
- empty_count
# Find all the available rules by running:
# swiftlint rules
#included: # paths to include during linting. `--path` is ignored if present.
# - Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
- .build/*
# - Source/*/ExcludedFile.swift # Exclude files with a wildcard
#analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
# - explicit_self

# configurable rules can be customized from this configuration file
# binary rules can set their severity level
#force_cast: warning

force_try: error

line_length: 120
type_body_length: 300

trailing_whitespace:
ignores_empty_lines: true

file_length:
warning: 500
error: 1200

function_parameter_count:
warning: 10
error: 12

type_name:
min_length: 3 # only warning
max_length: # warning and error
warning: 40
error: 50
excluded: # excluded via string
- iPhone
- API

reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown)
17 changes: 13 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "90ec71199435280f9d8d386a03d53eb33fb9f21e8c0d16cfceec6064cb667f62",
"originHash" : "f9be8c8ed296a68d20026c7c747ee039877b4b149b9f97ff593e9c506737683a",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -121,10 +121,10 @@
{
"identity" : "openedx-app-foundation-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/raccoongang/openedx-app-foundation-ios.git",
"location" : "https://github.com/openedx/openedx-app-foundation-ios.git",
"state" : {
"revision" : "ab2748ed7f7977c02ec834de3bfd2630574d20e9",
"version" : "0.1.0"
"revision" : "90f7897455908f4e71042596a669ae9253b91441",
"version" : "1.0.0"
}
},
{
Expand All @@ -145,6 +145,15 @@
"version" : "1.28.2"
}
},
{
"identity" : "swiftlintplugins",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SimplyDanny/SwiftLintPlugins",
"state" : {
"revision" : "7c80ce6f142164b0201871e580b021d1b2c69804",
"version" : "0.57.0"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
Expand Down
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/openedx/openedx-app-foundation-ios.git", from: "1.0.0"),
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "11.3.0")
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "11.3.0"),
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "0.57.0")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand All @@ -26,8 +27,10 @@ let package = Package(
name: "OEXFirebaseAnalytics",
dependencies: [
.product(name: "OEXFoundation", package: "openedx-app-foundation-ios"),
.product(name: "FirebaseMessaging", package: "firebase-ios-sdk"),
.product(name: "FirebaseAnalytics", package: "firebase-ios-sdk")
],
plugins: [
.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")
]
),
.testTarget(
Expand Down
48 changes: 48 additions & 0 deletions PrepareSarifToUpload.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import Foundation

let fileName = "swiftlint.report.sarif"
let errorLevel = "error"
let warningThresholdRuleId = "warning_threshold"

let currentDirectoryURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
let fileURL = currentDirectoryURL.appendingPathComponent(fileName)

do {
// Load the file data
let data = try Data(contentsOf: fileURL)

// Decode JSON data
if var jsonObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
var runs = jsonObject["runs"] as? [[String: Any]],
!runs.isEmpty {

if var results = runs[0]["results"] as? [[String: Any]], !results.isEmpty {
// Filter out results based on the condition
results = results.filter { result in
let level = result["level"] as? String
let ruleId = result["ruleId"] as? String
// Keep results that don't match the deletion condition
return !(level == errorLevel && ruleId == warningThresholdRuleId)
}

// Update the modified results array back into the runs structure
runs[0]["results"] = results
jsonObject["runs"] = runs

// Encode the updated JSON data back to Data
let updatedData = try JSONSerialization.data(withJSONObject: jsonObject, options: [.prettyPrinted])

// Write the updated data back to the file
try updatedData.write(to: fileURL)
print("Filtered JSON file updated successfully.")
} else {
print("No results found to filter.")
}
} else {
print("The JSON structure is not in the expected format.")
}
} catch {
print("Error reading or writing JSON file: \(error.localizedDescription)")
}

exit(0)
4 changes: 4 additions & 0 deletions Sources/OEXFirebaseAnalytics/FirebaseAnalyticsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ public extension String {
return replacingOccurrences(of: string, with: replacement, options: NSString.CompareOptions.literal, range: nil)
}
}

func unusedFuncWithWrongFormatting(){

Check warning

Code scanning / SwiftLint

Opening braces should be preceded by a single space and on the same line as the declaration Warning

Opening braces should be preceded by a single space and on the same line as the declaration

}

0 comments on commit 6f26f85

Please sign in to comment.