Skip to content

Commit

Permalink
updated dependencies to latest (#63)
Browse files Browse the repository at this point in the history
- Updated test file to follow the latest pattern
- Updated github actions to use the latest version
- Updated dependencies to latest version
- Implemented eng-automation/js-style deployed library
  - Before we were using the git hash
- Updated version to 0.3.2
- Updated publish script
  - It's the same as in
[auto-merge-bot](https://github.com/paritytech/auto-merge-bot/blob/main/.github/workflows/release.yml)
  • Loading branch information
Bullrich committed Mar 11, 2024
1 parent 3cc7f36 commit 0a497b0
Show file tree
Hide file tree
Showing 18 changed files with 2,059 additions and 1,096 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.git
23 changes: 16 additions & 7 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
const { getConfiguration } = require("opstooling-js-style/src/eslint/configuration");

const tsConfParams = { rootDir: __dirname };

const conf = getConfiguration({ typescript: tsConfParams });

module.exports = conf;
const {
getConfiguration,
getTypescriptOverride,
} = require("@eng-automation/js-style/src/eslint/configuration");

const tsConfParams = { rootDir: __dirname };

const conf = getConfiguration({ typescript: tsConfParams });

const tsConfOverride = getTypescriptOverride(tsConfParams);
conf.overrides.push({
...tsConfOverride,
rules: { "@typescript-eslint/strict-boolean-expressions": 0 },
});

module.exports = conf;
2 changes: 1 addition & 1 deletion .github/workflows/github-issue-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.PROJECT_APP_ID }}
private_key: ${{ secrets.PROJECT_APP_KEY }}
Expand Down
40 changes: 29 additions & 11 deletions .github/workflows/javascript-test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
name: Continuous testing

on: [pull_request]
on:
pull_request:
push:
branches: ["master"]

jobs:
test:
strategy:
matrix:
command: [lint, build, test]
runs-on: ubuntu-latest
name: running ${{ matrix.command }}
steps:
- uses: actions/checkout@v3
- name: Use node 18
uses: actions/setup-node@v3
- uses: actions/checkout@v4.1.1
- uses: actions/setup-node@v4.0.2
with:
node-version: 18
node-version: 20
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn test
- name: Run lint
run: yarn lint
- name: Build the project
run: yarn build
- run: yarn run ${{ matrix.command }}

conclude:
runs-on: ubuntu-latest
name: All tests passed
needs: [test]
steps:
- run: echo '### Good job! All the tests passed 🚀' >> $GITHUB_STEP_SUMMARY
129 changes: 45 additions & 84 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,109 +7,70 @@ on:

env:
IMAGE_NAME: action
REGISTRY: ghcr.io

jobs:
test-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.1
- name: Check that the image builds
run: docker build . --file Dockerfile

test-versions:
compare-versions:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.verification.outputs.VERSION }}
exists: ${{ steps.checkTag.outputs.exists }}
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.1
- name: Extract package.json version
id: package_version
run: echo "VERSION=$(jq '.version' -r package.json)" >> $GITHUB_OUTPUT
- name: Extract action.yml version
uses: mikefarah/yq@master
id: action_image
with:
cmd: yq '.runs.image' 'action.yml'
- name: Parse action.yml version
id: action_version
run: |
echo "IMAGE_VERSION=$(echo $IMAGE_URL | cut -d: -f3)" >> $GITHUB_OUTPUT
env:
IMAGE_URL: ${{ steps.action_image.outputs.result }}
# Compare that the versions contain the same name
- name: Compare versions
run: |
echo "Verifying that $IMAGE_VERSION from action.yml is the same as $PACKAGE_VERSION from package.json"
[[ $IMAGE_VERSION == $PACKAGE_VERSION ]]
env:
IMAGE_VERSION: ${{ steps.action_version.outputs.IMAGE_VERSION }}
PACKAGE_VERSION: ${{ steps.package_version.outputs.VERSION }}

tag:
if: github.event_name == 'push'
needs: [test-image, test-versions]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tagcreated: ${{ steps.autotag.outputs.tagcreated }}
tagname: ${{ steps.autotag.outputs.tagname }}
steps:
- uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- uses: butlerlogic/action-autotag@stable
id: autotag
id: verification
uses: Bullrich/compare-version-on-action@main
with:
head_branch: master
tag_prefix: "v"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Changelog
uses: Bullrich/generate-release-changelog@2.0.2
id: Changelog
env:
REPO: ${{ github.repository }}
- name: Create Release
if: steps.autotag.outputs.tagname != ''
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotag.outputs.tagname }}
release_name: Release ${{ steps.autotag.outputs.tagname }}
body: |
${{ steps.Changelog.outputs.changelog }}
version: ${{ steps.package_version.outputs.VERSION }}
# Verifies if there is a tag with that version number
- uses: mukunku/tag-exists-action@v1.4.0
if: steps.verification.outputs.VERSION
id: checkTag
with:
tag: v${{ steps.package_version.outputs.VERSION }}

publish:
if: github.event_name == 'push' && needs.compare-versions.outputs.exists == 'false'
needs: [test-image, compare-versions]
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs: [tag]
if: needs.tag.outputs.tagname != ''
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- uses: actions/checkout@v4.1.1
- name: Tag version and create release
run: gh release create $VERSION --generate-notes
env:
TAG: ${{ needs.tag.outputs.tagname }}
VERSION: v${{ needs.compare-versions.outputs.version }}
GH_TOKEN: ${{ github.token }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: ${{ needs.compare-versions.outputs.version }}
- uses: actions/checkout@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Because this project is intended to be used with a token we need to do an extra
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ inputs:
type: string
runs:
using: 'docker'
image: 'docker://ghcr.io/paritytech/github-issue-sync/action:0.3.1'
image: 'docker://ghcr.io/paritytech/github-issue-sync/action:0.3.2'
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-issue-sync",
"version": "0.3.1",
"version": "0.3.2",
"description": "Synchronize issues to GitHub Project boards",
"author": "Parity <admin@parity.io> (https://parity.io)",
"repository": {
Expand All @@ -22,18 +22,18 @@
"lint": "yarn eslint && yarn prettier"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@octokit/rest": "^19.0.5"
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/rest": "^20.0.2"
},
"devDependencies": {
"@octokit/graphql-schema": "^12.41.1",
"@types/jest": "^29.2.6",
"@vercel/ncc": "^0.36.1",
"jest": "^29.3.1",
"jest-mock-extended": "^3.0.1",
"opstooling-js-style": "https://github.com/paritytech/opstooling-js-style#c298d0f732d93712e4397fd53baa3317a3022c8c",
"ts-jest": "^29.0.5",
"typescript": "^4.9.4"
"@eng-automation/js-style": "^2.3.0",
"@octokit/graphql-schema": "^14.58.0",
"@types/jest": "^29.5.12",
"@vercel/ncc": "^0.38.1",
"jest": "^29.7.0",
"jest-mock-extended": "^3.0.5",
"ts-jest": "^29.1.2",
"typescript": "^5.4.2"
}
}
16 changes: 13 additions & 3 deletions src/github/issueKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ import { IIssues, Issue, Repository } from "./types";

export class IssueApi implements IIssues {
/** Requires permissions to the repository with access to the repo */
constructor(private readonly octokit: InstanceType<typeof GitHub>, private readonly repoData: Repository) {}
constructor(
private readonly octokit: InstanceType<typeof GitHub>,
private readonly repoData: Repository,
) {}

async getIssueState(issueId: number): Promise<"open" | "closed"> {
const { owner, repo } = this.repoData;
const issueData = await this.octokit.rest.issues.get({ repo, owner, issue_number: issueId });
const issueData = await this.octokit.rest.issues.get({
repo,
owner,
issue_number: issueId,
});
return issueData.data.state === "open" ? "open" : "closed";
}

async getAllIssues(excludeClosed: boolean, labels?: string[]): Promise<Issue[]> {
async getAllIssues(
excludeClosed: boolean,
labels?: string[],
): Promise<Issue[]> {
const allIssues = await this.octokit.rest.issues.listForRepo({
...this.repoData,
state: excludeClosed ? "open" : "all",
Expand Down
Loading

0 comments on commit 0a497b0

Please sign in to comment.