Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
komish committed Dec 19, 2023
1 parent 4fb71b8 commit 7d71ed1
Show file tree
Hide file tree
Showing 70 changed files with 6,631 additions and 211 deletions.
100 changes: 50 additions & 50 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main", "gh-pages" ]
release:
types: [published]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
- name: Display the dispatching event
env:
e: ${{ toJson(github.event) }}
run: echo "Event Date - $e"
ensure-valid-submitter:
uses: ./.github/workflows/check-chart-locks.yml
with:
# Real-world use case would introspect this data and then pass it to this workflow.
category: community
organization: examplecom
chartname: wildfly
# # This is a basic workflow to help you get started with Actions

# name: CI

# # Controls when the workflow will run
# on:
# # Triggers the workflow on push or pull request events but only for the "main" branch
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main", "gh-pages" ]
# release:
# types: [published]

# # Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:

# # A workflow run is made up of one or more jobs that can run sequentially or in parallel
# jobs:
# # This workflow contains a single job called "build"
# build:
# # The type of runner that the job will run on
# runs-on: ubuntu-latest

# # Steps represent a sequence of tasks that will be executed as part of the job
# steps:
# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# - uses: actions/checkout@v3

# # Runs a single command using the runners shell
# - name: Run a one-line script
# run: echo Hello, world!

# # Runs a set of commands using the runners shell
# - name: Run a multi-line script
# run: |
# echo Add other actions to build,
# echo test, and deploy your project.

# - name: Display the dispatching event
# env:
# e: ${{ toJson(github.event) }}
# run: echo "Event Date - $e"
# ensure-valid-submitter:
# uses: ./.github/workflows/check-chart-locks.yml
# with:
# # Real-world use case would introspect this data and then pass it to this workflow.
# category: community
# organization: examplecom
# chartname: wildfly

84 changes: 42 additions & 42 deletions .github/workflows/check-chart-locks.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# Check Chart Locks review the existing chart locks and fails if
# the submission does not existing in the right directory structure.
name: Ensure Submitter is Valid
# # Check Chart Locks review the existing chart locks and fails if
# # the submission does not existing in the right directory structure.
# name: Ensure Submitter is Valid

on:
workflow_call:
inputs:
category:
required: true
type: string
description: The category of the submission. (e.g. "partner", choose from [redhat, partner, community])
organization:
required: true
type: string
description: The submitting organization (e.g. "hashicorp")
chartname:
required: true
type: string
description: The name of the chart (e.g. "vault")
# on:
# workflow_call:
# inputs:
# category:
# required: true
# type: string
# description: The category of the submission. (e.g. "partners", choose from [redhat, partners, community])
# organization:
# required: true
# type: string
# description: The submitting organization (e.g. "hashicorp")
# chartname:
# required: true
# type: string
# description: The name of the chart (e.g. "vault")

env:
LOCKFILE_URL: https://komish.github.io/actions-workflow-call-test/lock.json
# env:
# LOCKFILE_URL: https://komish.github.io/actions-workflow-call-test/lock.json

jobs:
assert-chart-not-locked-or-locked-but-valid:
runs-on: ubuntu-latest
steps:
- name: Assemble directory path
id: assemble-path
run: |
set -o pipefail
echo "dirpath=${{ inputs.category }}/${{ inputs.organization }}/${{ inputs.chartname }}" | tee -a $GITHUB_OUTPUT
- name: Read entry from current Lockfile
run: |
wget "${{ env.LOCKFILE_URL }}" -O lock.json
md5sum lock.json
- name: Compare lockpaths
run: |
lockpath=$(jq -r .packages.${{ inputs.chartname }} lock.json)
test "${lockpath}" == "null" \
&& { echo "No lock found for chart ${{ inputs.chartname }}. We're clear to merge this in."; exit 0 ;}
test "${lockpath}" = "${{ steps.assemble-path.outputs.dirpath }}" \
&& { echo "Lock found for chart ${{ inputs.chartname }} and submission is coming from the correct path ${{ steps.assemble-path.outputs.dirpath }}."; exit 0 ;}
# jobs:
# assert-chart-not-locked-or-locked-but-valid:
# runs-on: ubuntu-latest
# steps:
# - name: Assemble directory path
# id: assemble-path
# run: |
# set -o pipefail
# echo "dirpath=${{ inputs.category }}/${{ inputs.organization }}/${{ inputs.chartname }}" | tee -a $GITHUB_OUTPUT
# - name: Read entry from current Lockfile
# run: |
# wget "${{ env.LOCKFILE_URL }}" -O lock.json
# md5sum lock.json
# - name: Compare lockpaths
# run: |
# lockpath=$(jq -r .packages.${{ inputs.chartname }} lock.json)
# test "${lockpath}" == "null" \
# && { echo "No lock found for chart ${{ inputs.chartname }}. We're clear to merge this in."; exit 0 ;}
# test "${lockpath}" = "${{ steps.assemble-path.outputs.dirpath }}" \
# && { echo "Lock found for chart ${{ inputs.chartname }} and submission is coming from the correct path ${{ steps.assemble-path.outputs.dirpath }}."; exit 0 ;}

echo "::error::Submission is invalid. The chart name '${{ inputs.chartname }}' is locked to submissions from path '${lockpath}' and this submission appears to come from '${{ steps.assemble-path.outputs.dirpath }}'"
exit 1
# echo "::error::Submission is invalid. The chart name '${{ inputs.chartname }}' is locked to submissions from path '${lockpath}' and this submission appears to come from '${{ steps.assemble-path.outputs.dirpath }}'"
# exit 1

43 changes: 43 additions & 0 deletions .github/workflows/checks-content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Check Content

on:
pull_request_target:
types: [opened, synchronize, reopened, edited, ready_for_review, labeled]

jobs:
check-content:
name: Check Content
runs-on: ubuntu-20.04
if: |
github.event.pull_request.draft == false
steps:
- name: Checkout Repository Base
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install CI Scripts
run: |
# set up python scripts
echo "set up python script in $PWD"
python3 -m venv ve1
cd scripts
../ve1/bin/pip3 install -r requirements.txt
../ve1/bin/pip3 install .
cd ..
- name: Check contributor
run: |
./ve1/bin/user-is-repo-owner ${{ github.event.pull_request.user.login }}
run-after:
name: Runs After
needs: check-content
runs-on: ubuntu-20.04
if: |
github.event.pull_request.draft == false
steps:
- run: |
echo "Woo hoo!"
Loading

0 comments on commit 7d71ed1

Please sign in to comment.