-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from IronCoreLabs/ci-fixup
Ci fixup
- Loading branch information
Showing
5 changed files
with
195 additions
and
207 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
# Copy the requested templates from the templates repo to this one, applying patches as we go. | ||
# You must be in the target repo when you run this, and depot must be checked out as a sibling to this repo. | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
if [ $# -lt 1 ] ; then | ||
echo "Must list workflow files to update." 1>&2 | ||
exit 1 | ||
fi | ||
WORKFLOWS=$* | ||
|
||
for X in jsonpatch yaml2json json2yaml ; do | ||
if ! command -v ${X} &> /dev/null ; then | ||
echo "Can't find ${X} on the PATH." 1>&2 | ||
exit 1 | ||
fi | ||
done | ||
|
||
THISREPO=$(git rev-parse --show-toplevel) | ||
TEMPLATES="${THISREPO}/../depot/github-actions" | ||
|
||
mkdir -p "${THISREPO}/.github/workflows" | ||
for WF in ${WORKFLOWS} ; do | ||
echo "Updating ${WF}..." | ||
BASE=$(basename "${WF}" .yaml) | ||
YAMLPATCH=".github/${BASE}-patch.yaml" | ||
JSONPATCH="/tmp/${BASE}-patch.json" | ||
|
||
# Copy the workflow file, using jsonpatch. | ||
( | ||
echo "# DO NOT EDIT THIS FILE." | ||
echo "# Instead, edit the jsonpatch file (actually YAML) in ${YAMLPATCH}" | ||
echo "# For docs, see github-actions in the IronCoreLabs/depot repo." | ||
echo "" | ||
if [ -f "${THISREPO}/${YAMLPATCH}" ] ; then | ||
yaml2json < "${THISREPO}/${YAMLPATCH}" > "${JSONPATCH}" | ||
yaml2json < "${TEMPLATES}/${WF}" | jsonpatch - "${JSONPATCH}" | json2yaml | ||
else | ||
yaml2json < "${TEMPLATES}/${WF}" | json2yaml | ||
fi | ||
) > "${THISREPO}/.github/workflows/${WF}" | ||
|
||
# Copy any related files or directories with the same name. | ||
find "${TEMPLATES}" -name "${BASE}.*" ! -name "${BASE}.yaml" -exec cp -r {} "${THISREPO}/.github" \; | ||
|
||
# If there's an example patch file in depot, but none in this repo, copy it over. | ||
# If you add an example patch file that's really optional, you'll need to change this logic. | ||
SRCPATCH="${TEMPLATES}/examples/${BASE}-patch.yaml" | ||
DSTPATCH="${THISREPO}/.github/${BASE}-patch.yaml" | ||
if [ -f "${SRCPATCH}" ] && ! [ -f "${DSTPATCH}" ] ; then | ||
echo "" | ||
echo "Copying ${SRCPATCH} to ${DSTPATCH}; make sure you customize it." | ||
cp "${SRCPATCH}" "${DSTPATCH}" | ||
# Be annoying to catch the user's attention. | ||
echo "" | ||
echo "" | ||
sleep 5 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,87 @@ | ||
# This workflow does version management, bumping the patch version on the main branch after a PR is merged. | ||
|
||
# Requirements: | ||
# - It needs a GitHub secret named WORKFLOW_PAT with a personal access token that has workflow permissions. The user that owns the | ||
# PAT must be allowed to push to the main branch of the repo. That usually means the user has to be a repo admin, and admins must | ||
# be excepted from branch protection rules on main. | ||
# - Another workflow must consume the prereleases created by this one. That workflow should build and publish the release. | ||
# You shouldn't need to customize this workflow. | ||
|
||
# Details: | ||
# This workflow is triggered by merge to main, or by manual workflow_dispatch. | ||
# 1. Remove any `-pre` or similar pre-release info from the semver. Commit, push, tag, and create a prerelease. | ||
# 2. Bump the patch version of the semver, and add `-pre` as a pre-release identifier. Commit and push. | ||
# It parses the version info from files in the repo like Cargo.toml, package.json, or version.sbt. It updates those files when it | ||
# bumps the version. | ||
# Sanity checks ensure it's a valid semver, and it's not 0.0.0. | ||
# DO NOT EDIT THIS FILE. | ||
# Instead, edit the jsonpatch file (actually YAML) in .github/bump-version-patch.yaml | ||
# For docs, see github-actions in the IronCoreLabs/depot repo. | ||
|
||
name: Bump Version | ||
|
||
'on': | ||
push: | ||
branches: | ||
# WARNING: Because this workflow pushes to main, we need more filtering in the job below to ensure we don't busy loop. | ||
- main | ||
- main | ||
workflow_dispatch: null | ||
|
||
env: | ||
COMMIT_PREFIX: 'bump-version: ' | ||
|
||
jobs: | ||
# This job exists solely to export env.COMMIT_PREFIX in a way that we can use it in the "if" of the "bump" job. | ||
# See https://github.community/t/how-to-set-and-access-a-workflow-variable/17335/16. | ||
vars: | ||
runs-on: ubuntu-20.04 | ||
outputs: | ||
commit-prefix: ${{ steps.echo.outputs.commit-prefix }} | ||
steps: | ||
- id: echo | ||
run: echo "::set-output name=commit-prefix::${{ env.COMMIT_PREFIX }}" | ||
|
||
- id: echo | ||
run: echo "::set-output name=commit-prefix::${{ env.COMMIT_PREFIX }}" | ||
bump: | ||
needs: | ||
- vars | ||
- vars | ||
runs-on: ubuntu-20.04 | ||
if: '!contains(join(github.event.commits.*.message), needs.vars.outputs.commit-prefix)' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.WORKFLOW_PAT }} | ||
- name: Configure git | ||
run: | | ||
git config --global user.email [email protected] | ||
git config --global user.name "Leeroy Travis" | ||
- name: Get version | ||
id: versions | ||
run: | | ||
set -x | ||
VERSION=$(.github/bump-version.sh) | ||
echo "::set-output name=old::${VERSION}" | ||
VERSION="${VERSION/-*}" | ||
echo "::set-output name=release::${VERSION}" | ||
VERSION="$(echo "${VERSION}" | awk -F. -v OFS=. '{$NF++;print}')-pre" | ||
echo "::set-output name=bumped::${VERSION}" | ||
- name: Set release version | ||
run: | | ||
.github/bump-version.sh "${{ steps.versions.outputs.release }}" | ||
git diff --cached | ||
- name: Commit and push release tag | ||
run: | | ||
git commit -m "${COMMIT_PREFIX}Set release version ${{ steps.versions.outputs.release }}" | ||
git tag "${{ steps.versions.outputs.release }}" | ||
git push origin main "${{ steps.versions.outputs.release }}" | ||
- name: Create prerelease | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.WORKFLOW_PAT }} | ||
prerelease: true | ||
tag: ${{ steps.versions.outputs.release }} | ||
- name: Bump version and set pre-release | ||
run: | | ||
.github/bump-version.sh "${{ steps.versions.outputs.bumped }}" | ||
git diff --cached | ||
- name: Commit and push pre-release version | ||
run: | | ||
git commit -m "${COMMIT_PREFIX}Bump to next pre-release version ${{ steps.versions.outputs.bumped }}" | ||
git push origin main | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.WORKFLOW_PAT }} | ||
- name: Configure git | ||
run: 'git config --global user.email [email protected] | ||
git config --global user.name "Leeroy Travis" | ||
' | ||
- name: Get version | ||
id: versions | ||
run: 'set -x | ||
VERSION=$(.github/bump-version.sh) | ||
echo "::set-output name=old::${VERSION}" | ||
VERSION="${VERSION/-*}" | ||
echo "::set-output name=release::${VERSION}" | ||
VERSION="$(echo "${VERSION}" | awk -F. -v OFS=. ''{$NF++;print}'')-pre" | ||
echo "::set-output name=bumped::${VERSION}" | ||
' | ||
- name: Set release version | ||
run: '.github/bump-version.sh "${{ steps.versions.outputs.release }}" | ||
git diff --cached | ||
' | ||
- name: Commit and push release tag | ||
run: 'git commit -m "${COMMIT_PREFIX}Set release version ${{ steps.versions.outputs.release | ||
}}" | ||
git tag "${{ steps.versions.outputs.release }}" | ||
git push origin main "${{ steps.versions.outputs.release }}" | ||
' | ||
- name: Create prerelease | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.WORKFLOW_PAT }} | ||
prerelease: true | ||
tag: ${{ steps.versions.outputs.release }} | ||
- name: Bump version and set pre-release | ||
run: '.github/bump-version.sh "${{ steps.versions.outputs.bumped }}" | ||
git diff --cached | ||
' | ||
- name: Commit and push pre-release version | ||
run: 'git commit -m "${COMMIT_PREFIX}Bump to next pre-release version ${{ steps.versions.outputs.bumped | ||
}}" | ||
git push origin main | ||
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
# CI tasks for Node (TypeScript, JavaScript) repositories. | ||
|
||
# Customization: | ||
# - Any custom setup steps can be inserted after step 0. (path: /jobs/test/steps/1 in typescript-ci-patch.yaml) | ||
# - Add/Remove/Replace the Node versions in the matrix. (path: /jobs/test/strategy/matrix/node_version in typescript-ci-patch.yaml) | ||
# DO NOT EDIT THIS FILE. | ||
# Instead, edit the jsonpatch file (actually YAML) in .github/typescript-ci-patch.yaml | ||
# For docs, see github-actions in the IronCoreLabs/depot repo. | ||
|
||
name: TypeScript CI | ||
|
||
'on': | ||
push: | ||
branches: | ||
- main | ||
- main | ||
pull_request: null | ||
workflow_dispatch: null | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
node_version: | ||
- "12" | ||
- '12' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: c-hive/gha-yarn-cache@v1 | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
- name: Install modules | ||
run: yarn | ||
- name: Run tests | ||
run: yarn run test | ||
- name: Check test coverage | ||
if: github.base_ref != '' | ||
uses: anuraag016/[email protected] | ||
with: | ||
fullCoverageDiff: false | ||
delta: 0.2 | ||
- uses: actions/checkout@v2 | ||
- uses: c-hive/gha-yarn-cache@v1 | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
- name: Install modules | ||
run: yarn | ||
- name: Run tests | ||
run: yarn run test | ||
- name: Check test coverage | ||
if: github.base_ref != '' | ||
uses: anuraag016/[email protected] | ||
with: | ||
fullCoverageDiff: false | ||
delta: 0.2 |
Oops, something went wrong.