Skip to content

Commit

Permalink
feat: rollback structure (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Oct 20, 2020
1 parent 3372dcf commit d90cd7c
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 32 deletions.
160 changes: 150 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,153 @@
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
#
# The MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

version: 2.1
# Use a package of configuration called an orb.
orbs:
# Declare a dependency on the welcome-orb
welcome: circleci/[email protected]
# Orchestrate or schedule a set of jobs

commands:
influxdb-onboarding:
steps:
- run:
name: "Install onBoarding dependencies"
command: |
apt-get update
apt-get install wget
apt-get install curl
apt-get install ruby --yes
gem install xcpretty
- run:
name: "Post onBoarding request to InfluxDB 2"
command: ./Scripts/influxdb-onboarding.sh
prepare:
description: "Prepare environment to tests"
steps:
- checkout
- influxdb-onboarding

jobs:
tests-swift:
parameters:
swift-image:
type: string
default: &default-swift-image "swift:5.3"
influxdb-image:
type: string
default: &default-influxdb-image "influxdb:2.0.0-rc"
docker:
- image: << parameters.swift-image >>
- image: &influx-image quay.io/influxdb/<< parameters.influxdb-image >>
environment:
INFLUXD_HTTP_BIND_ADDRESS: :8086
steps:
- prepare
- restore_cache:
name: Restoring Package Cache
keys:
- &cache-key package-cache-{{ checksum "Package.swift" }}-<< parameters.swift-image >>
- package-cache-{{ checksum "Package.swift" }}
- package-cache-
- run:
name: Install dependencies
command: swift package update
- run:
name: Run tests
command: |
swift build
swift test --enable-code-coverage 2>&1 | xcpretty --report junit
llvm-cov export -format="lcov" .build/debug/influxdb-client-swiftPackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
- save_cache:
name: Saving Package Cache
key: *cache-key
paths:
- Package.resolved
- ./builde/repositories
- store_test_results:
path: build/
- run:
name: Collecting coverage reports
command: bash <(curl -s https://codecov.io/bash) -f ./info.lcov || echo "Codecov did not collect coverage reports"

check-code-style:
docker:
- image: *default-swift-image
steps:
- checkout
- run: |
apt-get update
apt-get install wget unzip --yes
wget https://github.com/realm/SwiftLint/releases/download/0.40.3/swiftlint_linux.zip
unzip -n swiftlint_linux.zip
- run:
name: Checks style consistency across sources.
command: ./swiftlint lint

check-documentation:
docker:
- image: *default-swift-image
steps:
- checkout
- restore_cache:
name: Restoring Cache
keys:
- &documentation-cache-key sc-cache-v2-swift:5.3
- run:
name: Build SourceKitten and jazzy
command: |
apt-get update
apt-get install ruby-dev libsqlite3-dev --yes
gem install jazzy
if [ ! -f ./SourceKitten/.build/debug/sourcekitten ]; then
git clone https://github.com/jpsim/SourceKitten.git
cd SourceKitten
swift build
cd ../
fi
- run:
name: Checks generating docs.
command: |
swift build
SourceKitten/.build/debug/sourcekitten doc --spm > doc.json
jazzy --sourcekitten-sourcefile doc.json --config .jazzy.yml
- save_cache:
name: Saving Cache
key: *documentation-cache-key
paths:
- ./SourceKitten/.build/debug/sourcekitten
- /var/lib/gems/

workflows:
# Name the workflow "welcome"
welcome:
# Run the welcome/run job in its own container
version: 2
build:
jobs:
- welcome/run
- check-code-style
- check-documentation
- tests-swift:
name: swift-5.3
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- tests-swift
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ _Briefly describe your proposed changes:_
- [ ] CHANGELOG.md updated
- [ ] Rebased/mergeable
- [ ] A test has been added if appropriate
- [ ] `make check` completes successfully
- [ ] `swift test` completes successfully
- [ ] Commit messages are in [semantic format](https://seesparkbox.com/foundry/semantic_commit_messages)
- [ ] Sign [CLA](https://influxdata.com/community/cla/) (if not already signed)
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ iOSInjectionProject/

# JetBrains
.idea/

# Documentation
docs/
doc.json
SourceKitten/
6 changes: 6 additions & 0 deletions .jazzy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
author: InfluxData
author_url: https://www.influxdata.com
github_url: https://github.com/bonitoo-io/influxdb-client-swift
module: influxdb_client_swift
swift_build_tool: spm
clean: true
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.3
41 changes: 41 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
opt_in_rules:
- array_init
- collection_alignment
- contains_over_first_not_nil
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- empty_count
- empty_string
- explicit_acl
- explicit_init
- explicit_self
- fatal_error_message
- first_where
- force_unwrapping
- implicit_return
- missing_docs
- modifier_order
- multiline_arguments
- multiline_literal_brackets
- multiline_parameters
- operator_usage_whitespace
- pattern_matching_keywords
- redundant_nil_coalescing
- redundant_type_annotation
- sorted_first_last
- sorted_imports
- trailing_closure
- unneeded_parentheses_in_closure_argument
- unused_import
- unused_declaration
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces

excluded:
- build
- .build
- Package.swift
- Tests/LinuxMain.swift
- Tests/influxdb-client-swiftTests/XCTestManifests.swift
6 changes: 6 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import PackageDescription

let package = Package(
name: "influxdb-client-swift",
// platforms: [
// .macOS(.v11),
// .iOS(.v14),
// .watchOS(.v7),
// .tvOS(.v14)
// ],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,43 @@ This repository contains the reference Swift client for the InfluxDB 2.0.

## Features

TBD

## Supported Platforms

This package requires Swift 5 and Xcode 12.

- iOS 14.0+
- macOS 11.0+
- tvOS 14.0+
- watchOS 7.0+
- Linux

## Installation

TBD
### Swift Package Manager

Add this line to your `Package.swift` :

~~~swift
.Package(url: "https://github.com/bonitoo-io/influxdb-client-swift", from: "0.0.1")
~~~

### CocoaPods

Add this line to your `Podfile`:

~~~ruby
pod 'influxdb-client-swift', '~> 0.0.1'
~~~

### Carthage

Add this line to your Cartfile:

~~~
github "bonitoo-io/influxdb-client-swift" ~> 0.0.1
~~~

## Usage

Expand All @@ -44,7 +78,29 @@ TBD

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bonitoo-io/influxdb-client-swift.
If you would like to contribute code you can do through GitHub by forking the repository and sending a pull request into the `master` branch.

Build Requirements:

- swift 5.3 or higher

Run tests:

```bash
$ swift test
```

Check code coverage:

```bash
$ swift test --enable-code-coverage
```

Build distributions:

```bash
$ swift build
```

## License

Expand Down
39 changes: 39 additions & 0 deletions Scripts/influxdb-onboarding.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
#
# The MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

set -e

echo "Wait to start InfluxDB 2.0"
wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:8086/metrics

echo
echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)"
echo
curl -i -X POST http://localhost:8086/api/v2/setup -H 'accept: application/json' \
-d '{
"username": "my-user",
"password": "my-password",
"org": "my-org",
"bucket": "my-bucket",
"token": "my-token"
}'
7 changes: 7 additions & 0 deletions Sources/influxdb-client-swift/InfluxDBClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Created by Jakub Bednář on 20/10/2020.
//

/// A InfluxDB Client providing a support for APIs to write and query data.
public class InfluxDBClient {
}
3 changes: 0 additions & 3 deletions Sources/influxdb-client-swift/influxdb_client_swift.swift

This file was deleted.

3 changes: 2 additions & 1 deletion Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import XCTest
import influxdb_client_swiftTests

var tests = [XCTestCaseEntry]()
XCTMain(tests)
tests += influxdb_client_swiftTests.allTests()
XCTMain(tests)
Loading

0 comments on commit d90cd7c

Please sign in to comment.