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

chore(ci): upgrade to codecov v4 #20

Merged
merged 5 commits into from
Sep 14, 2023
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
36 changes: 18 additions & 18 deletions .github/workflows/swift_macos-10.15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@ name: Github Actions Swift Standard
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
jobs:
test-and-standard-upload:
runs-on: macos-10.15
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: actions/checkout@v4
- uses: actions/setup-python@v2
- run: pip install requests
- name: Install xcode-install
run: gem install xcode-install
- name: Install xcode 11.7
run: xcversion install 11.7
- name: Install xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Xcode Version
run: xcodebuild -version
- name: Build and Test
env:
API_KEY: ${{ secrets.API_KEY }}
CORRECT_COVERAGE: ${{ secrets.CORRECT_COVERAGE }}
run: |
xcodebuild -scheme standard-swift -sdk iphonesimulator -derivedDataPath Build/ -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.4' -enableCodeCoverage YES clean build test
xcodebuild -scheme standard-swift -sdk iphonesimulator -derivedDataPath Build/ -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.2' -enableCodeCoverage YES clean build test
cd Build/Build/ProfileData
cd $(ls -d */|head -n 1)
directory=${PWD##*/}
pathCoverage=Build/Build/ProfileData/${directory}/Coverage.profdata
cd ../../../../
xcrun llvm-cov export -format="lcov" -instr-profile $pathCoverage Build/Build/Products/Debug-iphonesimulator/standard-swift.app/standard-swift > info.lcov
curl -Os https://uploader.codecov.io/latest/macos/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}
python request.py
- name: Upload to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
- name: Test coverage vaulue
run: python request.py
env:
API_KEY: ${{ secrets.API_KEY }}
CORRECT_COVERAGE: ${{ secrets.CORRECT_COVERAGE }}
- name: Upstream to Standards
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
15 changes: 9 additions & 6 deletions request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

payload = {'token': os.environ['API_KEY']}

link = 'https://codecov.io/api/gh/codecov/Swift-Standard'
link = 'https://api.codecov.io/api/v2/github/codecov/repos/Swift-Standard/commits'

print("Waiting 60 seconds for report to upload before pinging API...")

Expand All @@ -16,14 +16,17 @@
print("Pinging Codecov's API..")
#get latest coverage data
all_data = requests.get(link, params=payload).json()
commit_data = all_data['commits'][0]
coverage_percentage = commit_data['totals']['c']
commit_data = all_data['results'][0]
coverage_percentage = commit_data['totals']['coverage']

print("Ensuring coverage percentage is accurate...")
#result should return 86.66667 as its coverage metric
if(coverage_percentage == os.environ['CORRECT_COVERAGE']):
print("Success! Codecov's API returned the correct coverage percentage, "+ os.environ['CORRECT_COVERAGE'])
if(str(coverage_percentage) == os.environ['CORRECT_COVERAGE']):
print(
"Success! Codecov's API returned the correct coverage percentage, ",
os.environ['CORRECT_COVERAGE']
)
exit(0)
else:
print("Whoops, something is wrong D: Codecov did not return the correct coverage percentage. Coverage percentage should be "+os.environ['CORRECT_COVERAGE']+" but Codecov returned "+coverage_percentage)
print("Whoops, something is wrong D: Codecov did not return the correct coverage percentage. Coverage percentage should be ",os.environ['CORRECT_COVERAGE']," but Codecov returned ",coverage_percentage)
exit(1)
11 changes: 5 additions & 6 deletions standard-swiftTests/Test_Index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ import XCTest
@testable import standard_swift

class TestIndex: XCTestCase {

private var indexObj: Index!

override func setUp() {
super.setUp()
// Using this, a new instance of Index will be created
// before each test is run.
indexObj = Index()
}

func test_uncovered_if() {
XCTAssertFalse(indexObj.uncovered_if())
}

func test_fully_covered() {
XCTAssertTrue(indexObj.fully_covered())
}



}

13 changes: 2 additions & 11 deletions standard-swiftUITests/Test_Index_UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,12 @@ class Test_Index_UI: XCTestCase {
XCUIApplication().launch()
sleep(10)
}

//Check to see if the label for the first button is correct
func testFirstButtonLabel() {

let app = XCUIApplication()
let buttonsQuery = app.buttons
XCTAssertEqual(buttonsQuery.firstMatch.label,"Eli, Wise Falcon")
}

//Check to see if AFTER the first button is clicked, the correct information shows up
func testCheckFirstButtonInfo() {
let app = XCUIApplication()
let tablesQuery = app.tables
tablesQuery.buttons["Eli, Wise Falcon"].tap()
XCTAssertEqual(app.staticTexts.element(boundBy: 2).label, "CTO")

}
}
Loading