diff --git a/.github/workflows/containerization-build-template.yml b/.github/workflows/containerization-build-template.yml new file mode 100644 index 00000000..41bb5871 --- /dev/null +++ b/.github/workflows/containerization-build-template.yml @@ -0,0 +1,115 @@ +name: Build containerization template + +on: + workflow_call: + inputs: + release: + type: boolean + description: "Create a release" + default: false + version: + type: string + description: Version of containerization + default: test + +jobs: + buildAndTest: + name: Build and Test repo + timeout-minutes: 90 + runs-on: [self-hosted, macos, sequoia, ARM64] + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Activate Swiftly + run: | + source /opt/swiftly/env.sh + cat /opt/swiftly/env.sh + - name: Check formatting + run: | + ./scripts/install-hawkeye.sh + make fmt + git diff + if ! git diff --quiet ; then echo the following files require formatting or license headers: ; git diff --name-only ; false ; fi + env: + DEVELOPER_DIR: "/Applications/Xcode_16.3.app/Contents/Developer" + - name: Check protobufs + run: | + make protos + if ! git diff --quiet ; then echo the following files require formatting or license headers: ; git diff --name-only ; false ; fi + env: + DEVELOPER_DIR: "/Applications/Xcode_16.3.app/Contents/Developer" + CURRENT_SDK: y + - name: Make containerization and docs + run: | + make clean containerization docs + tar cfz _site.tgz _site + env: + DEVELOPER_DIR: "/Applications/Xcode_16.3.app/Contents/Developer" + CURRENT_SDK: y + - name: Make vminitd image + run: | + source /opt/swiftly/env.sh + make -C vminitd linux-sdk + make init + env: + CURRENT_SDK: y + - name: Test containerization + run: | + make test integration + env: + REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REGISTRY_USERNAME: ${{ github.actor }} + DEVELOPER_DIR: "/Applications/Xcode_16.3.app/Contents/Developer" + CURRENT_SDK: y + - name: Push vminitd image + if: ${{ inputs.release }} + run: | + bin/cctl images tag vminit:latest ghcr.io/apple-uat/containerization/vminit:${{ inputs.version }} + bin/cctl images push ghcr.io/apple-uat/containerization/vminit:${{ inputs.version }} + env: + REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REGISTRY_USERNAME: ${{ github.actor }} + REGISTRY_HOST: ghcr.io + - name: Create image tar + if: ${{ inputs.release }} != true + run: | + bin/cctl images save vminit:latest -o vminit.tar + - name: Save vminit artifact + if: ${{ inputs.release }} != true + uses: actions/upload-artifact@v4 + with: + name: vminit + path: vminit.tar + - name: Save documentation artifact + uses: actions/upload-artifact@v4 + with: + name: api-docs + path: "./_site.tgz" + retention-days: 14 + uploadPages: + # Separate upload step required because upload-pages-artifact needs + # gtar which is not on the macOS runner. + name: Upload artifact for GitHub Pages + needs: buildAndTest + timeout-minutes: 5 + runs-on: ubuntu-latest + + steps: + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Download a single artifact + uses: actions/download-artifact@v4 + with: + name: api-docs + - name: Add API docs to documentation + run: | + tar xfz _site.tgz + - name: Upload Artifact + uses: actions/upload-pages-artifact@v3 + with: + path: "./_site" \ No newline at end of file diff --git a/.github/workflows/containerization-build.yml b/.github/workflows/containerization-build.yml new file mode 100644 index 00000000..ffa444bb --- /dev/null +++ b/.github/workflows/containerization-build.yml @@ -0,0 +1,18 @@ +name: Build containerization + +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + - release/* + +jobs: + containerization: + permissions: + contents: read + packages: write + pages: write + uses: ./.github/workflows/containerization-build-template.yml + secrets: inherit diff --git a/.github/workflows/docs-release.yaml b/.github/workflows/docs-release.yaml new file mode 100644 index 00000000..82db2d1e --- /dev/null +++ b/.github/workflows/docs-release.yaml @@ -0,0 +1,28 @@ +name: Deploy application website +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" +permissions: + contents: read + packages: write + pages: write + +jobs: + buildSite: + name: Build application website + uses: ./.github/workflows/containerization-build-template.yml + secrets: inherit + + deploy: + runs-on: ubuntu-latest + needs: buildSite + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..748ce703 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,17 @@ +name: Release containerization + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + containerization: + permissions: + contents: read + packages: write + uses: ./.github/workflows/containerization-build-template.yml + with: + release: true + version: ${{ github.ref_name }} + secrets: inherit diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..28485db6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +.DS_Store +bin +libexec +.build +.local +xcuserdata/ +DerivedData/ +.swiftpm/ +.netrc +.swiftpm +workdir/ +installer/ +.xcode/ +.vscode/ +.venv/ +test_results/ +*.pid +*.log +*.zip +*.o +*.ext4 +*.pkg +*.swp + +# API docs for local preview only. +_site/ diff --git a/.swift-format b/.swift-format new file mode 100644 index 00000000..dcd60059 --- /dev/null +++ b/.swift-format @@ -0,0 +1,68 @@ +{ + "fileScopedDeclarationPrivacy" : { + "accessLevel" : "private" + }, + "indentation" : { + "spaces" : 4 + }, + "indentConditionalCompilationBlocks" : false, + "indentSwitchCaseLabels" : false, + "lineBreakAroundMultilineExpressionChainComponents" : false, + "lineBreakBeforeControlFlowKeywords" : false, + "lineBreakBeforeEachArgument" : false, + "lineBreakBeforeEachGenericRequirement" : false, + "lineLength" : 180, + "maximumBlankLines" : 1, + "multiElementCollectionTrailingCommas" : true, + "noAssignmentInExpressions" : { + "allowedFunctions" : [ + "XCTAssertNoThrow" + ] + }, + "prioritizeKeepingFunctionOutputTogether" : false, + "respectsExistingLineBreaks" : true, + "rules" : { + "AllPublicDeclarationsHaveDocumentation" : false, + "AlwaysUseLowerCamelCase" : true, + "AmbiguousTrailingClosureOverload" : false, + "BeginDocumentationCommentWithOneLineSummary" : false, + "DoNotUseSemicolons" : true, + "DontRepeatTypeInStaticProperties" : true, + "FileScopedDeclarationPrivacy" : true, + "FullyIndirectEnum" : true, + "GroupNumericLiterals" : true, + "IdentifiersMustBeASCII" : true, + "NeverForceUnwrap" : true, + "NeverUseForceTry" : true, + "NeverUseImplicitlyUnwrappedOptionals" : true, + "NoAccessLevelOnExtensionDeclaration" : true, + "NoAssignmentInExpressions" : true, + "NoBlockComments" : false, + "NoCasesWithOnlyFallthrough" : true, + "NoEmptyTrailingClosureParentheses" : true, + "NoLabelsInCasePatterns" : true, + "NoLeadingUnderscores" : false, + "NoParensAroundConditions" : true, + "NoPlaygroundLiterals" : true, + "NoVoidReturnOnFunctionSignature" : true, + "OmitExplicitReturns" : true, + "OneCasePerLine" : true, + "OneVariableDeclarationPerLine" : true, + "OnlyOneTrailingClosureArgument" : true, + "OrderedImports" : true, + "ReplaceForEachWithForLoop" : true, + "ReturnVoidInsteadOfEmptyTuple" : true, + "TypeNamesShouldBeCapitalized" : true, + "UseEarlyExits" : true, + "UseLetInEveryBoundCaseVariable" : true, + "UseShorthandTypeNames" : true, + "UseSingleLinePropertyGetter" : true, + "UseSynthesizedInitializer" : true, + "UseTripleSlashForDocumentationComments" : true, + "UseWhereClausesInForLoops" : false, + "ValidateDocumentationComments" : true + }, + "spacesAroundRangeFormationOperators" : false, + "tabWidth" : 2, + "version" : 1 +} diff --git a/.swift-version b/.swift-version new file mode 100644 index 00000000..358e78e6 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +6.1.0 \ No newline at end of file