Skip to content

Commit

Permalink
chore(ci): switch to GHA from circleci (#1312)
Browse files Browse the repository at this point in the history
* chore(ci): first pass at build-linux

* fix: add npm ci step

* test: logs

* fix: stop running circleci and echo

* fix: add ./

* fix: just try vendor dir

* fix: comment out things and see if the ls is brekaing it

* fix: specify the entire dir

* test: ls again

* test: what about package.json

* fix: is it the name?

* test: cat the file

* fix: upload everything

* fix: maybe just package.json

* fix: add a name

* fix: its not a list

* fix: upload them all

* fix: add windows and macos

* fix: add test linux

* fix: syntax

* fix: update build-windows needs

* fix: update needs

* fix: make binaries executable

* fix: get the perms

* fix: chmod

* fix: tee and choose a better file

* fix: underscore

* fix: try alpine

* fix: try to use a container

* fix: make some adjustments

* fix: test macos

* fix: update the makeup

* fix: test windows

* fix: undo circleci and rerun

* fix: update azure to use runExternalProgram

* fix: update azure test

* fix: make it stdout

* fix: remove unused removal

* fix: use the token

* fix: use a better shelel
  • Loading branch information
thomasrockhu-codecov authored Jan 10, 2024
1 parent 008480e commit 84244d3
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 10 deletions.
214 changes: 214 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
name: Test and Deploy

on:
pull_request:
push:
branches:
- main

# Remaining circleci jobs to port
# - build-aarch64:
# - test-alpine:
# - test-alpine-proxy:
# - test-alpine-without-git:
# - test-aarch64:
# - test-aarch64-without-git:
# - test-linux-without-git:
# - test-macos-without-git:
# - test-windows-without-git:
# - review:
# - deploy:
# - release:

jobs:
build-linux-and-osx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install deps
run: npm ci
- name: Test
run: make test
- name: Build
run: make build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: |
coverage/
out/
package.json
vendor/
build-alpine:
runs-on: ubuntu-latest
container: alpine:3.18.4@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978
needs: build-linux-and-osx
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download prebuilt static node binary
run: |
apk add wget coreutils make
NODE_RELEASE=node.v16.2.0_b57a0d7c9ecba551879997ac44bba3c9d9443df5
wget https://github.com/codecov/node-static-alpine/releases/download/$NODE_RELEASE/node
wget https://github.com/codecov/node-static-alpine/releases/download/$NODE_RELEASE/SHA1SUM
wget https://github.com/codecov/node-static-alpine/releases/download/$NODE_RELEASE/SHA256SUM
wget https://github.com/codecov/node-static-alpine/releases/download/$NODE_RELEASE/SHA512SUM
for i in 1 256 512; do "sha${i}sum" -c "SHA${i}SUM"; done
- name: Confirm that alpine node binary is static
run: |
apk add file
(file node | grep 'static') || exit ${?}
- name: Create pkg-cache directory and copy static NodeJS binary
run: |
mkdir -p ~/.pkg-cache/v2.6
cp node ~/.pkg-cache/v2.6/fetched-v14.0.0-alpine-x64
- name: Remove downloaded binary and run tests
run: |
rm -rf node
apk add npm git
npm ci
npm test
mkdir -p coverage-alpine
cp -r coverage/* coverage-alpine/
- name: Build uploader binary on alpine
run: make build_alpine
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: |
coverage-alpine
out/codecov-alpine
build-windows:
runs-on: windows-latest
needs: build-linux-and-osx
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install deps
run: |
$ErrorActionPreference="Stop"
node --version
npm ci; npm test
- name: Build
run: |
$ErrorActionPreference="Stop"
npm run build; npm run build-windows
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: |
coverage/
out/codecov.exe
test-linux:
runs-on: ubuntu-latest
needs: build-linux-and-osx
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/download-artifact@v3
with:
name: artifact
- name: Confirm that linux uploader binary is static
run: (file out/codecov-linux | grep 'static') || exit ${?}
- name: Remove test coverage files
run: rm -rf *.coverage.txt coverage-report-test.json test/fixtures || echo
- name: Update exec permission
run: chmod u+x out/codecov-linux
- name: Run Linux binary -f (dry run)
run: |
out/codecov-linux -f coverage/cobertura-coverage.xml -F linux -d -Z -v -t ${{ secrets.CODECOV_TOKEN }} | tee output_linux.txt
- name: Run Linux binary auto-detect (dry run)
run: |
out/codecov-linux -F linux -d -Z | tee -a output_linux.txt
- name: Run Linux binary (upload)
run: |
out/codecov-linux -F linux -Z -t ${{ secrets.CODECOV_TOKEN }}
out/codecov-linux -F "-linux" -Z -t ${{ secrets.CODECOV_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: |
output_linux.txt
test-macos:
runs-on: macos-latest
needs: build-linux-and-osx
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: artifact
- name: Remove test coverage files
run: rm -rf *.coverage.txt coverage-report-test.json test/fixtures || echo
- name: Update exec permission
run: chmod u+x out/codecov-macos
- name: Run MacOS binary -f (dry-run)
run: |
out/codecov-macos -f coverage/cobertura-coverage.xml -F macos -d -Z -v -t ${{ secrets.CODECOV_TOKEN }} | tee output_osx.txt
- name: Run MacOS binary auto-detect (dry-run)
run: |
out/codecov-macos -F macos -v -d -Z -t ${{ secrets.CODECOV_TOKEN }} | tee -a output_osx.txt
- name: Run MacOS binary (upload)
run: |
out/codecov-macos -F macos -v -Z -t ${{ secrets.CODECOV_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: |
output_osx.txt
test-windows:
runs-on: windows-latest
needs: build-windows
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: artifact
- name: Remove test coverage files
run: |
Remove-Item -Recurse -Force *.coverage.txt; echo "ok"
Remove-Item -Recurse -Force test/fixtures; echo "ok"
- name: Run Windows binary -f (dry-run)
run: |
dir .
attrib .\coverage\cobertura-coveage.xml
.\out\codecov.exe -f .\coverage\cobertura-coverage.xml -F windows -d -Z -v -t ${{ secrets.CODECOV_TOKEN }} | tee output_win.txt
shell: cmd
- name: Run Windows binary auto-detect (dry-run)
run: |
.\out\codecov.exe -F windows -v -d -Z -t ${{ secrets.CODECOV_TOKEN }} | tee -a output_win.txt
shell: cmd
- name: Run Windows binary (upload)
run: |
.\out\codecov.exe -F windows -v -Z -t ${{ secrets.CODECOV_TOKEN }}
shell: cmd
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: |
output_win.txt
7 changes: 2 additions & 5 deletions src/ci_providers/provider_azurepipelines.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import childProcess from 'child_process'
import { parseSlugFromRemoteAddr } from '../helpers/git'
import { info } from '../helpers/logger'
import { runExternalProgram } from "../helpers/util"
import { IServiceParams, UploaderEnvs, UploaderInputs } from '../types'

export function detect(envs: UploaderEnvs): boolean {
Expand Down Expand Up @@ -59,10 +59,7 @@ function _getSHA(inputs: UploaderInputs): string {

if (_getPR(inputs)) {
const mergeCommitRegex = /^[a-z0-9]{40} [a-z0-9]{40}$/
const mergeCommitMessage = childProcess
.execFileSync('git', ['show', '--no-patch', '--format=%P'])
.toString()
.trimRight()
const mergeCommitMessage = runExternalProgram('git', ['show', '--no-patch', '--format=%P'])
if (mergeCommitRegex.exec(mergeCommitMessage)) {
const mergeCommit = mergeCommitMessage.split(' ')[1]
info(` Fixing merge commit SHA ${commit} -> ${mergeCommit}`)
Expand Down
10 changes: 5 additions & 5 deletions test/providers/provider_azurepipelines.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ describe('Azure Pipelines CI Params', () => {
service: 'azure_pipelines',
slug: 'testOrg/testRepo',
}
const execFileSync = td.replace(childProcess, 'execFileSync')
const spawnSync = td.replace(childProcess, 'spawnSync')
td.when(
execFileSync('git', ['show', '--no-patch', '--format=%P']),
).thenReturn(
Buffer.from('testingsha123456789012345678901234567890 testingmergecommitsha2345678901234567890'),
)
spawnSync('git', ['show', '--no-patch', '--format=%P'], { maxBuffer: SPAWNPROCESSBUFFERSIZE }),
).thenReturn({
stdout: Buffer.from('testingsha123456789012345678901234567890 testingmergecommitsha2345678901234567890'),
})
const params = await providerAzurepipelines.getServiceParams(inputs)
expect(params).toMatchObject(expected)
})
Expand Down

0 comments on commit 84244d3

Please sign in to comment.