Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS: Development #141

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Swiftlint
run: swiftlint --strict --reporter github-actions-logging

swiftformt:
swiftformat:
name: SwiftFormat
runs-on: ubuntu-latest
container:
Expand All @@ -37,16 +37,31 @@ jobs:

- name: SwiftFormat
run: swiftformat --lint .

markdownlint:
name: Markdownlint
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/igorshubovych/markdownlint-cli:latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Lint README
run: docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "README.md"
run: markdownlint "README.md"

- name: Lint DocC files
run: docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.docc/**/*.md"
run: markdownlint "**/*.docc/**/*.md"

# markdownlint:
# name: Markdownlint
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Lint README
# run: docker run --rm -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "README.md"

# - name: Lint DocC files
# run: docker run --rm -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.docc/**/*.md"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
xcuserdata/
.vscode
*.xctestplan
docs/
9 changes: 0 additions & 9 deletions Dockerfile

This file was deleted.

100 changes: 97 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,97 @@
linuxtest:
docker build -f Dockerfile -t linuxtest .
docker run linuxtest
TARGET = TMDb
TEST_TARGET = TMDbTests
INTEGRATION_TEST_TARGET = TMDbIntegrationTests

IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.2'
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2'
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2'

SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy

.PHONY: clean
clean:
swift package clean
rm -rf docs

.PHONY: format
swiftlint --fix
swiftformat .

.PHONY: lint
lint:
swiftlint --strict
swiftformat --lint .

.PHONY: lint-markdown
lint-markdown:
markdownlint "README.md"
markdownlint "**/*.docc/**/*.md"

.PHONY: build
build:
swift build

.PHONY: build-linux
build-linux:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors"

.PHONY: build-release
build-release:
swift build -c release -Xswiftc -warnings-as-errors

.PHONY: build-linux-release
build-linux-release:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release -Xswiftc -warnings-as-errors"

.PHONY: build-docs
build-docs:
SWIFTCI_DOCC=1 swift package generate-documentation --product $(TARGET)
swift package resolve

.PHONY: docs
preview-docs:
SWIFTCI_DOCC=1 swift package --disable-sandbox preview-documentation --target $(TARGET)

.PHONY: generate-docs
generate-docs:
SWIFTCI_DOCC=1 swift package --allow-writing-to-directory docs \
generate-documentation --target $(TARGET) \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path $(TARGET) \
--output-path docs

.PHONY: test
test:
swift build -Xswiftc -warnings-as-errors --build-tests
swift test --skip-build --filter $(TEST_TARGET)

.PHONY: test-ios
test-ios:
xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION)
xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION)

.PHONY: test-watchos
test-watchos:
xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION)
xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION)

.PHONY: test-tvos
test-tvos:
xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION)
xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION)

.PHONY: test-linux
test-linux:
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors --build-tests && swift test --skip-build --filter $(TEST_TARGET)"

.PHONY: integration-test
integration-test: .check-env-vars
swift build --build-tests
swift test --skip-build --filter $(INTEGRATION_TEST_TARGET)

.PHONY: ci
ci: .check-env-vars lint lint-markdown test test-ios test-watchos test-tvos test-linux integration-test build-release build-docs

.check-env-vars:
@test $${TMDB_API_KEY?Please set environment variable TMDB_API_KEY}
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,86 @@ Create an API key from The Movie Database web site
Documentation and examples of usage can be found at
[https://adamayoung.github.io/TMDb/documentation/tmdb/](https://adamayoung.github.io/TMDb/documentation/tmdb/)

## Development

### Prerequisites

Install [homebrew](https://brew.sh) and the follow formulae

* swiftlint
* swiftformat
* markdownlint

```bash
brew install swiftlint swiftformat markdownlint
```

### Before submitting a PR

#### Unit and Integration Tests

Ensure all new code is covered by unit tests. If any new methods are added to
services that make calls to TMDb API endpoints, ensure there are integration tests
covering these.

#### Coding Style

Coding style is enforced by `swiftlint` and `swiftformat`.

Use the following command to lint the codebase:

```bash
make lint
```

To format the codebase use:

```bash
make format
```

#### DocC Documentation

Ensure all `public` classes, structs, properties and methods are commented

The DocC documentation can be built and hosted locally by

```bash
make preview-docs
```

See [DocC | Apple Developer Documentation](https://developer.apple.com/documentation/docc)
for more details.

#### CI Checks

Before submitting a PR, ensure all CI checks will pass:

```bash
make ci
```

CI checks are made up of the follow tasks:

```bash
make lint
make lint-markddown
make test
make test-ios
make test-watchos
make test-tvos
make test-linux
make integration-test
make build-release
make build-docs
```

In order to run integration tests the `TMDB_API_KEY` environment variable needs
to be set.

Running unit tests on Linux requires [Docker](https://www.docker.com) to be
running.

## References

* [https://www.themoviedb.org](https://www.themoviedb.org)
Expand Down