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

chore(scripts): catch up on deprecated github actions #1345

Merged
merged 5 commits into from
Feb 28, 2023
Merged
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
13 changes: 5 additions & 8 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ inputs:
type:
description: Type of setup, `minimal` will only setup the JavaScript monorepo, `matrix` will set the run variables.
required: false
workflow_name:
description: Name of the workflow that is executing this action.
required: false
language:
description: the language for which to install deps
required: false
Expand All @@ -24,7 +21,7 @@ runs:
# Java for code generation
- name: Install Java
if: inputs.type != 'minimal'
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11.0.4
Expand All @@ -41,15 +38,15 @@ runs:

# JavaScript for monorepo and tooling
- name: Install Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn

- name: Get yarn cache directory path
shell: bash
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Restore Yarn
uses: actions/cache@v3
Expand All @@ -73,7 +70,7 @@ runs:
if: ${{ inputs.language == 'javascript' }}
shell: bash
id: yarn-cache-dir-client
run: echo "::set-output name=dir::$(cd clients/algoliasearch-client-javascript && yarn config get cacheFolder)"
run: echo "dir=$(cd clients/algoliasearch-client-javascript && yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Restore Yarn js-client
if: ${{ inputs.language == 'javascript' }}
Expand Down Expand Up @@ -134,7 +131,7 @@ runs:
run: |
if ${{ steps.gen-matrix.outputs.RUN_GEN_JAVASCRIPT || steps.diff.outputs.JAVASCRIPT_UTILS_CHANGED > 0 }}; then
echo "Running JavaScript utils: true"
echo "::set-output name=RUN_JS_UTILS::true"
echo "RUN_JS_UTILS=true" >> $GITHUB_OUTPUT
fi

outputs:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
needs: setup
if: ${{ needs.setup.outputs.RUN_SCRIPTS == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -97,7 +97,7 @@ jobs:
timeout-minutes: 10
needs: setup
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Cache bundled specs
id: cache
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- requester-node-http
- requester-fetch
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Cache '${{ matrix.client }}' client folder
id: cache
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.GEN_MATRIX) }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Cache clients folder
id: cache
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
if: ${{ matrix.client.language == 'javascript' }}
shell: bash
id: yarn-cache-dir-tests
run: echo "::set-output name=dir::$(cd ${{ matrix.client.testsRootFolder }} && yarn config get cacheFolder)"
run: echo "dir=$(cd ${{ matrix.client.testsRootFolder }} && yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Restore Yarn js tests
if: ${{ matrix.client.language == 'javascript' }}
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
!contains(needs.*.result, 'cancelled') &&
!contains(needs.*.result, 'failure')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
timeout-minutes: 10
if: (github.event.action == 'opened' || github.event.action == 'synchronize') && github.event.number
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
Expand All @@ -32,7 +32,7 @@ jobs:
timeout-minutes: 10
if: github.event.action == 'closed'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Pull Request title rules
uses: deepakputhraya/action-pr-title@v1.0.2
uses: Slashgear/action-check-pr-title@v4.3.0
with:
regex: '^(docs|chore)|((?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\((?:clients|generators|javascript|php|java|cts|specs|scripts|ci|templates|deps)\)): .+'
regexp: '^(docs|chore)|((?:feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)\((?:clients|generators|javascript|php|java|cts|specs|scripts|ci|templates|deps)\)): .+'
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Scheduled Release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_PRIVATE_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PRIVATE_KEY_PASSWORD }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Java
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11.0.4
Expand All @@ -36,7 +36,7 @@ jobs:
id: snapshot
run: |
if [[ $(cat ./gradle.properties | grep 'VERSION_NAME=.*-SNAPSHOT') ]]; then
echo "::set-output name=IS_SNAPSHOT::true"
echo "IS_SNAPSHOT=true" >> $GITHUB_OUTPUT
fi

- name: Release Artifacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-20.04
if: "startsWith(github.event.head_commit.message, 'chore: release')"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
Expand Down
17 changes: 9 additions & 8 deletions scripts/ci/githubActions/createMatrix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-console,no-case-declarations */
/* eslint-disable no-case-declarations */
import * as core from '@actions/core';

import { CLIENTS, createClientName, GENERATORS, LANGUAGES } from '../../common';
import {
getClientsConfigField,
Expand Down Expand Up @@ -150,16 +152,15 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
testsToDelete,
testsToStore,
});
console.log(`::set-output name=RUN_GEN_${language.toUpperCase()}::true`);
core.setOutput(`RUN_GEN_${language.toUpperCase()}`, true);
}

const shouldRun = clientMatrix.client.length > 0;

console.log(`::set-output name=RUN_GEN::${shouldRun}`);
console.log(
`::set-output name=GEN_MATRIX::${JSON.stringify(
shouldRun ? clientMatrix : EMPTY_MATRIX
)}`
core.setOutput('RUN_GEN', shouldRun);
core.setOutput(
'GEN_MATRIX',
JSON.stringify(shouldRun ? clientMatrix : EMPTY_MATRIX)
);
}

Expand Down Expand Up @@ -187,7 +188,7 @@ async function getSpecMatrix(): Promise<void> {
]),
};

console.log(`::set-output name=MATRIX::${JSON.stringify(ciMatrix)}`);
core.setOutput('MATRIX', JSON.stringify(ciMatrix));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion scripts/ci/githubActions/setRunVariables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-console */
import * as core from '@actions/core';

import { CLIENTS_JS_UTILS } from '../../common';
import { getLanguageFolder } from '../../config';

Expand Down Expand Up @@ -81,7 +83,7 @@ async function setRunVariables({
}): Promise<void> {
console.log(`Checking diff between ${originBranch} and HEAD`);

console.log(`::set-output name=ORIGIN_BRANCH::${originBranch}`);
core.setOutput('ORIGIN_BRANCH', originBranch);

await isBaseChanged(originBranch, DEPENDENCIES, true);
}
Expand Down
10 changes: 5 additions & 5 deletions scripts/ci/githubActions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
import crypto from 'crypto';

import * as core from '@actions/core';
import { hashElement } from 'folder-hash';

import { toAbsolutePath } from '../../common';
import { getNbGitDiff } from '../utils';

/**
* This cache key holds the hash of the common dependencies of all the clients.
*/
Expand Down Expand Up @@ -63,22 +63,22 @@ export async function computeCacheKey(
/**
* Determines if changes have been found in the `dependencies`, compared to the `baseBranch`.
*
* If `setOutput` is true, it will set log the variable values for the CI.
* If `output` is true, it will set log the variable values for the CI.
*/
export async function isBaseChanged(
baseBranch: string,
dependencies: Record<string, string[]>,
setOutput?: boolean
output?: boolean
): Promise<boolean> {
for (const [key, path] of Object.entries(dependencies)) {
const diff = await getNbGitDiff({
branch: baseBranch,
path: path.join(' '),
});

if (setOutput) {
if (output) {
console.log(`Found ${diff} changes for '${key}'`);
console.log(`::set-output name=${key}::${diff}`);
core.setOutput(key, diff);
} else if (diff > 0) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"upsertGenerationComment": "ts-node ci/codegen/upsertGenerationComment.ts"
},
"devDependencies": {
"@actions/core": "1.10.0",
"@octokit/rest": "19.0.7",
"@types/folder-hash": "4.0.2",
"@types/inquirer": "8.2.6",
Expand Down
29 changes: 28 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ __metadata:
version: 6
cacheKey: 8

"@actions/core@npm:1.10.0":
version: 1.10.0
resolution: "@actions/core@npm:1.10.0"
dependencies:
"@actions/http-client": ^2.0.1
uuid: ^8.3.2
checksum: 0a75621e007ab20d887434cdd165f0b9036f14c22252a2faed33543d8b9d04ec95d823e69ca636a25245574e4585d73e1e9e47a845339553c664f9f2c9614669
languageName: node
linkType: hard

"@actions/http-client@npm:^2.0.1":
version: 2.0.1
resolution: "@actions/http-client@npm:2.0.1"
dependencies:
tunnel: ^0.0.6
checksum: 799ec3df91e28a9da91ce6592e94f8b8923ccf6cc21a2f72c7429be5af5273f1625335411adc2a1bb222d56c852d5767214dfa6fa32a6da7e81dba8290e08f17
languageName: node
linkType: hard

"@algolia/api-client-automation@workspace:.":
version: 0.0.0-use.local
resolution: "@algolia/api-client-automation@workspace:."
Expand Down Expand Up @@ -7943,6 +7962,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "scripts@workspace:scripts"
dependencies:
"@actions/core": 1.10.0
"@octokit/rest": 19.0.7
"@types/folder-hash": 4.0.2
"@types/inquirer": 8.2.6
Expand Down Expand Up @@ -8686,6 +8706,13 @@ __metadata:
languageName: node
linkType: hard

"tunnel@npm:^0.0.6":
version: 0.0.6
resolution: "tunnel@npm:0.0.6"
checksum: c362948df9ad34b649b5585e54ce2838fa583aa3037091aaed66793c65b423a264e5229f0d7e9a95513a795ac2bd4cb72cda7e89a74313f182c1e9ae0b0994fa
languageName: node
linkType: hard

"type-check@npm:^0.4.0, type-check@npm:~0.4.0":
version: 0.4.0
resolution: "type-check@npm:0.4.0"
Expand Down Expand Up @@ -8837,7 +8864,7 @@ __metadata:
languageName: node
linkType: hard

"uuid@npm:8.3.2":
"uuid@npm:8.3.2, uuid@npm:^8.3.2":
version: 8.3.2
resolution: "uuid@npm:8.3.2"
bin:
Expand Down