Skip to content

Add GH Action for CI #886

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

Merged
merged 10 commits into from
Feb 4, 2025
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
push: { branches: [ main ] }

jobs:
soundness:
name: Soundness Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run script
run: ./scripts/soundness.sh

build-site:
name: Build the Jekyll Site
runs-on: ubuntu-latest
container: ruby:3.3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build site
run: bundle install && bundle exec jekyll build

test-openapi:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Run OpenAPI Tester
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to test that the JSON files backing the API actually still work, we'll need to start the jekyll server locally, and then tell the test CLI to fetch from that.

This might require installing Swift in the container based on the jekyll image, here in the pipeline. Or install jekyll into the Swift one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh ok. I've updated it so that we build the container and run that - also helps us test the container image is valid.

Since the default runner has Swift installed and Docker we shouldn't need to run it in a container

working-directory: openapi/TestSwiftOrgClient
env:
DOWNLOADSWIFTORG_SERVER_NAME: local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And SWIFTORG_SERVER_NAME=local is the other one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just beat you 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm you were faster and already did it 🫡

SWIFTORG_SERVER_NAME: local
run: |
docker compose -f ../../docker-compose.yaml run build
docker compose -f ../../docker-compose.yaml run -d -p 4000:4000 website
swift run swiftorgClient
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# docker-compose up website
#

version: "2"

services:

docker-setup:
Expand Down
14 changes: 14 additions & 0 deletions openapi/TestSwiftOrgClient/Shared/Tester.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import Foundation

package struct Test: Sendable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import OpenAPIRuntime
import HTTPTypes
import Foundation
Expand Down
17 changes: 17 additions & 0 deletions openapi/TestSwiftOrgClient/downloadswiftorgClient/Tool.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import OpenAPIURLSession
import Foundation
import Shared

enum DownloadSwiftOrgServerName: String {
case prod
case local
}

@main
Expand All @@ -17,6 +32,8 @@ struct Tool {
switch serverName {
case .prod:
serverURL = try Servers.Server1.url()
case .local:
serverURL = try Servers.Server2.url()
}
} else {
serverURL = try Servers.Server1.url()
Expand Down
14 changes: 14 additions & 0 deletions openapi/TestSwiftOrgClient/swiftorgClient/Tool.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import OpenAPIURLSession
import Foundation
import Shared
Expand Down
2 changes: 2 additions & 0 deletions openapi/downloadswiftorg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ info:
servers:
- url: https://download.swift.org
description: The production server.
- url: http://127.0.0.1:4000/api/v1
description: A local deployment.
tags:
- name: Evolution
description: Information about the Swift evolution process.
Expand Down
8 changes: 5 additions & 3 deletions scripts/soundness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function replace_acceptable_years() {
# this needs to replace all acceptable forms with 'YEARS'
sed -e 's/20[12][789012]-20[12][89012]/YEARS/' -e 's/20[12][89012]/YEARS/'
sed -e 's/20[2][0123456789]-20[2][0123456789]/YEARS/' -e 's/20[2][0123456789]/YEARS/'
}

printf "=> Checking for unacceptable language... "
Expand All @@ -45,11 +45,11 @@ tmp=$(mktemp /tmp/.swift-org-soundness_XXXXXX)
for language in swift-or-c bash python; do
declare -a matching_files
declare -a exceptions
expections=( )
exceptions=( )
matching_files=( -name '*' )
case "$language" in
swift-or-c)
exceptions=( -name "" )
exceptions=( -name "Package.swift" )
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
cat > "$tmp" <<"EOF"
//===----------------------------------------------------------------------===//
Expand All @@ -68,6 +68,7 @@ for language in swift-or-c bash python; do
EOF
;;
bash)
exceptions=( -name "placeholder" )
matching_files=( -name '*.sh' )
cat > "$tmp" <<"EOF"
#!/bin/bash
Expand All @@ -87,6 +88,7 @@ EOF
EOF
;;
python)
exceptions=( -name "placeholder" )
matching_files=( -name '*.py' )
cat > "$tmp" <<"EOF"
#!/usr/bin/env python
Expand Down