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

feat: actions/build-copr #17

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
lib/
node_modules/
jest.config.js
61 changes: 61 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{ "accessibility": "no-public" }
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{ "allowExpressions": true }
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
11 changes: 11 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly

- package-ecosystem: npm
directory: /
schedule:
interval: weekly
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
run-name: >
CI (${{ github.event_name }})
${{ github.event_name == 'pull_request' && format('PR#{0}', github.event.number) || '' }}

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
pre-commit:
uses: ./.github/workflows/step_pre-commit.yaml

setup-packit:
needs: [pre-commit]
uses: ./.github/workflows/step_test-setup-packit.yaml
with:
fas-user: ${{ vars.FAS_USER }}
secrets:
PACKIT_KEYTAB: ${{ secrets.PACKIT_KEYTAB }}

build-copr:
needs: [setup-packit]
uses: ./.github/workflows/step_test-build-copr.yaml
with:
fas-user: ${{ vars.FAS_USER }}
secrets:
PACKIT_KEYTAB: ${{ secrets.PACKIT_KEYTAB }}

pass:
name: ✅ Pass
needs: [pre-commit, setup-packit, build-copr]
runs-on: ubuntu-latest
steps:
- name: Check all CI jobs
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
if: always()
63 changes: 63 additions & 0 deletions .github/workflows/step_pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: pre-commit

on:
workflow_call:

permissions: {}

jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]

husky:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 20
- run: npm ci
- name: Run npm style-checks
run: |
npm run format
npm run lint

check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 20
- run: npm ci
- name: Rebuild the dist/ directory
run: |
npm run build
npm run package

- name: Compare the expected and actual dist/ directories
id: diff
run: |
if [[ ! -z $(git status --porcelain dist | grep -E "^.\S") ]]; then
echo "Detected uncommitted changes after build. See status below or the uploaded dist folder:"
echo "Please run: npm build && npm package && git add dist/"
echo "Currently cannot automatically push a git commit because it will not re-trigger the CI"
git status dist
exit 1
fi

- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
52 changes: 52 additions & 0 deletions .github/workflows/step_test-build-copr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
workflow_call:
inputs:
fas-user:
description: Fedora user to authenticate as
type: string
required: true
secrets:
PACKIT_KEYTAB:
description: Fedora user's keytab
required: true

permissions: {}

jobs:
test-default:
name: >
test-default
🐍 ${{ matrix.python || 'built-in' }}
${{ matrix.container && format('({0})', matrix.container) }}
${{ matrix.experimental && '[experimental]' }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
container: ["", "fedora:latest"]
python: ["", "3.x"]
include:
- python: "3.x"
experimental: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
if: matrix.python
- uses: ./setup-packit
with:
fas-user: ${{ inputs.fas-user }}
keytab: ${{ secrets.PACKIT_KEYTAB }}
- name: Get example project
uses: actions/checkout@v4
with:
repository: packit/hello-world
path: hello-world
- uses: ./build-copr
with:
path: hello-world
owner: lecris
project: hello_world
42 changes: 42 additions & 0 deletions .github/workflows/step_test-setup-packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
workflow_call:
inputs:
fas-user:
description: Fedora user to authenticate as
type: string
required: true
secrets:
PACKIT_KEYTAB:
description: Fedora user's keytab
required: true

permissions: {}

jobs:
test:
name: >
test
🐍 ${{ matrix.python || 'built-in' }}
${{ matrix.container && format('({0})', matrix.container) }}
${{ matrix.experimental && '[experimental]' }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
container: ["", "fedora:latest"]
python: ["", "3.x"]
include:
- python: "3.x"
experimental: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
if: matrix.python
- uses: ./setup-packit
with:
fas-user: ${{ inputs.fas-user }}
keytab: ${{ secrets.PACKIT_KEYTAB }}
Loading