Skip to content

Commit

Permalink
Change license and add soundness checks (#13)
Browse files Browse the repository at this point in the history
* chore: remove vscode settings

* feat: add license and soundness checks

* chore: apply swift format

* docs: update readme

* docs: add security + coc

* ci: update workflows

* ci: fix workflow

* ci: downgrade to actions v3

* ci: fix workflow

* ci: fix codeql

* ci: add api-breakage

* ci: fix ci

* ci: configure swift-format

* ci: fix

* ci: fix

* ci: cache swift-format

* ci: fix again

* ci: do not run CodeQL in container

* ci: fix typo

* test: add timeout case

* ci: test if this works :)

* ci: comment this out

* ci: add git

* ci: maybe this works

* ci: fix ownership issue again

* ci: remove comments
  • Loading branch information
lovetodream committed Apr 22, 2024
1 parent 4146f59 commit 1f78e5c
Show file tree
Hide file tree
Showing 35 changed files with 1,222 additions and 206 deletions.
17 changes: 17 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
changelog:
exclude:
labels:
- semver-noop
categories:
- title: SemVer Major
labels:
- semver-major
- title: SemVer Minor
labels:
- semver-minor
- title: SemVer Patch
labels:
- semver-patch
- title: Other Changes
labels:
- "*"
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
soundness:
container:
image: ghcr.io/lovetodream/swift-format-ci:v5.10.0

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Mark repo safe in non-fake global config
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Run soundness
run: |
scripts/soundness.sh
exit $(git status --porcelain | wc -l)
api-breakage:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
container: swift:jammy
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/766
- name: API breaking changes
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
swift package diagnose-api-breaking-changes origin/main
tests:
container:
image: swift:5.10-jammy

runs-on: ubuntu-latest

services:
loki:
image: grafana/loki:3.0.0

steps:
- uses: actions/checkout@v4
- name: Cache Swift PM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-ci-spm-${{ hashFiles('Package.swift') }}
restore-keys: ${{ runner.os }}-ci-spm-
- name: Resolve Swift dependencies
run: swift package resolve
- name: Build
run: swift build
- name: Run tests
run: swift test --enable-code-coverage
env:
XCT_LOKI_URL: http://loki:3100
- name: Prepare Code Coverage
run: |
llvm-cov export -format "lcov" \
.build/debug/swift-log-lokiPackageTests.xctest \
-ignore-filename-regex="\.pb\.swift" \
-ignore-filename-regex="\/Tests\/" \
-instr-profile .build/debug/codecov/default.profdata \
> info.lcov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: info.lcov
40 changes: 40 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions: { actions: write, contents: read, security-events: write }

steps:
- uses: actions/checkout@v4

- name: Mark repo safe in non-fake global config
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: swift

- name: Cache Swift PM
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-codeql-spm-${{ hashFiles('Package.swift') }}
restore-keys: ${{ runner.os }}-codeql-spm-

- name: Resolve Swift dependencies
run: swift package resolve

- name: Build
run: swift build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
34 changes: 0 additions & 34 deletions .github/workflows/tests.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentation": {
"spaces": 4
},
"indentConditionalCompilationBlocks": true,
"indentSwitchCaseLabels": false,
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineLength": 100,
"maximumBlankLines": 2,
"multiElementCollectionTrailingCommas": true,
"noAssignmentInExpressions": {
"allowedFunctions": [
"XCTAssertNoThrow"
]
},
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": false,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": false,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": false,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": false,
"ValidateDocumentationComments": false
},
"spacesAroundRangeFormationOperators": false,
"tabWidth": 8,
"version": 1
}
3 changes: 3 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

SwiftLogLoki adopts Swift's code of conduct: https://www.swift.org/code-of-conduct.
Loading

0 comments on commit 1f78e5c

Please sign in to comment.