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

[doc] Getting Started documentation and tutorial #300

Merged
merged 9 commits into from
Sep 11, 2023

Conversation

sebsto
Copy link
Contributor

@sebsto sebsto commented Apr 16, 2023

This is proposal for a getting started documentation and step-by-step tutorial.
This complements and replaces the original PR made by @fabianfett (#261)

Motivation:

Provide a step-by-step tutorials to help new comers to get started with the Swift AWS Lambda Runtime

Modifications:

  • create a top level documentation page for package AWSLambdaRuntimeCore. It contains a brief introduction to the project copied from the main README file) and links to other parts
  • a getting started guide for the impatient, with just top-level instructions
  • a step-by-step tutorial based on Swift Docs @tutorial format

Result:

There is a getting started documentation !
You can see a preview at this ephemeral address : https://staging.stormacq.com/lambda-runtime-doc/documentation/awslambdaruntimecore/

@sebsto sebsto changed the title Getting Started documentation and tutorial [doc] Getting Started documentation and tutorial Apr 16, 2023
@tomerd
Copy link
Contributor

tomerd commented Apr 18, 2023

cc @bitjammer

@tomerd
Copy link
Contributor

tomerd commented Apr 18, 2023

cc @Joannis

@tomerd
Copy link
Contributor

tomerd commented Apr 25, 2023

this is awesome!

@tomerd
Copy link
Contributor

tomerd commented Aug 1, 2023

@sebsto is this ready to be merged? its a great addition!

@tomerd
Copy link
Contributor

tomerd commented Aug 1, 2023

@swift-server-bot add to allowlist

@sebsto
Copy link
Contributor Author

sebsto commented Aug 1, 2023

@tomerd I am on PTO - hence the delay to answer questions. Yes, it is good for me and ready to publish

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

Hello @tomerd what is the blocker for this one and how can I help to release it ?

@tomerd
Copy link
Contributor

tomerd commented Sep 7, 2023

@sebsto no blocker, was confirming this was ready. looks like one CI job is not happy, but lets marge once green

@tomerd
Copy link
Contributor

tomerd commented Sep 7, 2023

@swift-server-bot test this please

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

I was inquiring about the failed CI Job :-) Looks like the soundness.sh script fails because swiftformat has not been applied.

But when I run swiftformat it updates many files that are not part of this PR ?

➜  swift-aws-lambda-runtime git:(sebsto/getting-started-doc) ✗ git status --porcelain
 M Examples/Foundation/Lambda.swift
 M Examples/LocalDebugging/MyApp/MyApp/ContentView.swift
 M Sources/AWSLambdaRuntimeCore/ControlPlaneRequest.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-01-package.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-02-package.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-04-package.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-05-package.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-01-main.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-02-main.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-03-main.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-04-main.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-05-main.swift
 M Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-06-main.swift
 M Sources/AWSLambdaRuntimeCore/HTTPClient.swift
 M Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift
 M Sources/AWSLambdaRuntimeCore/Lambda.swift
 M Sources/AWSLambdaRuntimeCore/LambdaConfiguration.swift
 M Sources/AWSLambdaRuntimeCore/LambdaHandler.swift
 M Sources/AWSLambdaRuntimeCore/LambdaRequestID.swift
 M Sources/AWSLambdaRuntimeCore/LambdaRunner.swift
 M Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift
 M Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift
 M Sources/AWSLambdaRuntimeCore/Terminator.swift
 M Sources/AWSLambdaRuntimeCore/Utils.swift
 M Sources/MockServer/main.swift
 M Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift
 M Tests/AWSLambdaRuntimeCoreTests/Utils.swift

Should I commit those as well ?

@tomerd
Copy link
Contributor

tomerd commented Sep 7, 2023

try to run in docker install of installing swift-format locally, as you may be using a different version than the one we use

docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.al2.58.yaml run soundness

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

@tomerd thank you swiftformat is now OK.
But soundness fails because the code snippets in the tutorial part do not have the license header file.

I think adding these to these code snippets will reduce the lisibility of the tutorial. soundness script makes no difference between source code file and code snippets from the doc, they all are *.swift

Can I modify soudness to skip files in the documentation directories ?

@tomerd
Copy link
Contributor

tomerd commented Sep 7, 2023

I think adding these to these code snippets will reduce the lisibility of the tutorial.

where would they be visible?

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

I think adding these to these code snippets will reduce the lisibility of the tutorial.

where would they be visible?

These are visible on the tutorial web page.
The tutorial shows code incrementally, step by step, as reader scrolls down. Each step is a separate .swift file.

See screenshot attached.
image

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

image

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

Also, the core runtime does not compile on Swift 5.9 or Swift nightly. This should be fixed on the main branch.

15:48:54 /code/Sources/AWSLambdaRuntimeCore/LambdaContext.swift:15:17: remark: '@preconcurrency' attribute on module 'Dispatch' is unused
15:48:54 @preconcurrency import Dispatch
15:48:54 ~~~~~~~~~~~~~~~~^
15:48:54 [282/295] Compiling AWSLambdaRuntimeCore LambdaContext.swift
15:48:54 /code/Sources/AWSLambdaRuntimeCore/LambdaContext.swift:15:17: remark: '@preconcurrency' attribute on module 'Dispatch' is unused
15:48:54 @preconcurrency import Dispatch
15:48:54 ~~~~~~~~~~~~~~~~^
15:48:54 [283/295] Compiling AWSLambdaRuntimeCore Lambda+String.swift
15:48:54 /code/Sources/AWSLambdaRuntimeCore/Lambda.swift:88:23: error: 'install()' is deprecated: This is no longer needed in Swift 5.9
15:48:54             Backtrace.install()
15:48:54                       ^
15:48:54 [284/295] Compiling AWSLambdaRuntimeCore Lambda.swift
15:48:54 /code/Sources/AWSLambdaRuntimeCore/Lambda.swift:88:23: error: 'install()' is deprecated: This is no longer needed in Swift 5.9
15:48:54             Backtrace.install()
15:48:54                       ^
15:48:54 error: fatalError
15:48:54 error: fatalError

@tomerd
Copy link
Contributor

tomerd commented Sep 7, 2023

These are visible on the tutorial web page.

right, but do license header show up as well? is there no way to filter them from DocC?

cc @bitjammer

@tomerd
Copy link
Contributor

tomerd commented Sep 7, 2023

Also, the core runtime does not compile on Swift 5.9 or Swift nightly. This should be fixed on the main branch.

yes, that should be done in a separate PR

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

Also, the core runtime does not compile on Swift 5.9 or Swift nightly. This should be fixed on the main branch.

yes, that should be done in a separate PR

I just opened #304

@sebsto
Copy link
Contributor Author

sebsto commented Sep 7, 2023

These are visible on the tutorial web page.

right, but do license header show up as well? is there no way to filter them from DocC?

cc @bitjammer

The code visible in the tutorial is assembled from individual *.swift files, one file for each code snippet.
I choose to not include the license header file in these *.swift files to keep the code snippets that are visible on the tutorial web page clean.

Problem : soundness script checks for the presence of the header in all swift files (it uses this command : find . -name '*.swift' -o -name '*.c' -o -name '*.h')

Proposed solution : add an exception for *.swift files inside *.docc folders

git diff scripts/soundness.sh 
diff --git a/scripts/soundness.sh b/scripts/soundness.sh
index bd321f6..353359d 100755
--- a/scripts/soundness.sh
+++ b/scripts/soundness.sh
@@ -130,6 +130,7 @@ EOF
     find . \
       \( \! -path '*/.build/*' -a \
       \( \! -path '*/.git/*' \) -a \
+      \( \! -path '*/Documentation.docc/*' \) -a \
       \( "${matching_files[@]}" \) -a \
       \( \! \( "${exceptions[@]}" \) \) \) | while read line; do
       if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then

@tomerd
Copy link
Contributor

tomerd commented Sep 8, 2023

Proposed solution : add an exception for *.swift files inside *.docc folders

I think that would be fine if we cannot find a way to tell DocC to ignore the license headers

cc @franklinsch

@tomerd
Copy link
Contributor

tomerd commented Sep 8, 2023

5.9 wanring fix: #305

motivation: swift 5.9 ships with builtin backtrace support \o/

changes:
* remove the dependency on swift-backtrace when using swift 5.9 or above
* conditionalize the call to Backtrace.install to relevant versions only
@bitjammer
Copy link

I don't believe there is a way to hide regions of code in tutorials. They use a different feature from "snippets", which do have different mechanisms for hiding regions of code.

@sebsto
Copy link
Contributor Author

sebsto commented Sep 9, 2023

Will be able to merge when #307 is approved

@sebsto
Copy link
Contributor Author

sebsto commented Sep 11, 2023

@swift-server-bot test this please

@sebsto
Copy link
Contributor Author

sebsto commented Sep 11, 2023

@tomerd thank you for merging #307, this PR is now ready to merge.

@tomerd tomerd merged commit c85c875 into swift-server:main Sep 11, 2023
sebsto added a commit to sebsto/swift-aws-lambda-runtime that referenced this pull request Dec 18, 2023
improved getting started documentation, with DocC
@sebsto sebsto deleted the sebsto/getting-started-doc branch December 18, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants