diff --git a/Dockerfile b/Dockerfile index 3ff5209a48a..2f50cde6cfe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN chmod +x /metrics/source/app/action/index.mjs \ # Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install # Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker && apt-get update \ - && apt-get install -y wget gnupg ca-certificates libgconf-2-4 \ + && apt-get install -y xz-utils wget gnupg ca-certificates libgconf-2-4 \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ && apt-get update \ diff --git a/source/plugins/achievements/queries/achievements.graphql b/source/plugins/achievements/queries/achievements.graphql index c7bcb13b334..ff276a195a0 100644 --- a/source/plugins/achievements/queries/achievements.graphql +++ b/source/plugins/achievements/queries/achievements.graphql @@ -47,7 +47,7 @@ query AchievementsDefault { totalCount } } - projects(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) { + projects: projectsV2(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) { totalCount #nodes { This requires additional scopes :/ # name diff --git a/source/plugins/achievements/queries/organizations.graphql b/source/plugins/achievements/queries/organizations.graphql index f50cc56f4f6..8ae4118f1e8 100644 --- a/source/plugins/achievements/queries/organizations.graphql +++ b/source/plugins/achievements/queries/organizations.graphql @@ -21,7 +21,7 @@ query AchievementsOrganizations { } } } - projects(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) { + projects: projectsV2(first: 1, orderBy: {field: CREATED_AT, direction: ASC}) { totalCount } packages(first: 1, orderBy: {direction: ASC, field: CREATED_AT}) { diff --git a/source/plugins/projects/index.mjs b/source/plugins/projects/index.mjs index 98dfe1ef05c..5963fb13d6a 100644 --- a/source/plugins/projects/index.mjs +++ b/source/plugins/projects/index.mjs @@ -15,10 +15,7 @@ export default async function({login, data, imports, graphql, q, queries, accoun //Retrieve user owned projects from graphql api console.debug(`metrics/compute/${login}/plugins > projects > querying api`) - const {[account]: {projects}} = await graphql(queries.projects["user.legacy"]({login, limit, account})) const {[account]: {projectsV2}} = await graphql(queries.projects.user({login, limit, account})) - projects.nodes.unshift(...projectsV2.nodes) - projects.totalCount += projectsV2.totalCount //Retrieve repositories projects from graphql api for (const identifier of repositories) { @@ -27,7 +24,7 @@ export default async function({login, data, imports, graphql, q, queries, accoun const {user, repository, id} = identifier.match(/(?[-\w]+)[/](?[-\w]+)[/]projects[/](?\d+)/)?.groups ?? {} let project = null for (const account of ["user", "organization"]) { - //Try projects beta + //Projects classic has been sunset, so ProjectsV2 is the only option try { project = (await graphql(queries.projects.repository({user, repository, id, account})))[account].repository.projectV2 if (project) @@ -36,30 +33,20 @@ export default async function({login, data, imports, graphql, q, queries, accoun catch (error) { console.debug(error) } - //Try projects classic - try { - console.debug(`metrics/compute/${login}/plugins > projects > falling back to projects classic for ${identifier}`) - ;({project} = (await graphql(queries.projects["repository.legacy"]({user, repository, id, account})))[account].repository) - if (project) - break - } - catch (error) { - console.debug(error) - } } if (!project) throw new Error(`Could not load project ${user}/${repository}`) //Adding it to projects list console.debug(`metrics/compute/${login}/plugins > projects > registering ${identifier}`) project.name = `${project.name} (${user}/${repository})` - projects.nodes.unshift(project) - projects.totalCount++ + projectsV2.nodes.unshift(project) + projectsV2.totalCount++ } //Iterate through projects and format them - console.debug(`metrics/compute/${login}/plugins > projects > processing ${projects.nodes.length} projects`) + console.debug(`metrics/compute/${login}/plugins > projects > processing ${projectsV2.nodes.length} projects`) const list = [] - for (const project of projects.nodes) { + for (const project of projectsV2.nodes) { //Format date const time = (Date.now() - new Date(project.updatedAt).getTime()) / (24 * 60 * 60 * 1000) let updated = new Date(project.updatedAt).toDateString().substring(4) @@ -85,7 +72,7 @@ export default async function({login, data, imports, graphql, q, queries, accoun list.splice(limit) //Results - return {list, totalCount: projects.totalCount, descriptions} + return {list, totalCount: projectsV2.totalCount, descriptions} } //Handle errors catch (error) { diff --git a/source/plugins/projects/queries/repository.legacy.graphql b/source/plugins/projects/queries/repository.legacy.graphql deleted file mode 100644 index 67f50a99954..00000000000 --- a/source/plugins/projects/queries/repository.legacy.graphql +++ /dev/null @@ -1,17 +0,0 @@ -query ProjectsRepositoryLegacy { - $account(login: "$user") { - repository(name: "$repository") { - project(number: $id) { - name - body - updatedAt - progress { - doneCount - inProgressCount - todoCount - enabled - } - } - } - } -} \ No newline at end of file diff --git a/source/plugins/projects/queries/user.legacy.graphql b/source/plugins/projects/queries/user.legacy.graphql deleted file mode 100644 index 2f31f94c2d5..00000000000 --- a/source/plugins/projects/queries/user.legacy.graphql +++ /dev/null @@ -1,18 +0,0 @@ -query ProjectsUserLegacy { - $account(login: "$login") { - projects(last: $limit, states: OPEN, orderBy: {field: UPDATED_AT, direction: DESC}) { - totalCount - nodes { - name - body - updatedAt - progress { - doneCount - inProgressCount - todoCount - enabled - } - } - } - } -} \ No newline at end of file diff --git a/tests/mocks/api/github/graphql/projects.repository.legacy.mjs b/tests/mocks/api/github/graphql/projects.repository.legacy.mjs deleted file mode 100644 index cff1bde9dea..00000000000 --- a/tests/mocks/api/github/graphql/projects.repository.legacy.mjs +++ /dev/null @@ -1,21 +0,0 @@ -/**Mocked data */ -export default function({faker, query, login = faker.internet.userName()}) { - console.debug("metrics/compute/mocks > mocking graphql api result > projects/repository.legacy") - return ({ - user: { - repository: { - project: { - name: "Repository project example", - updatedAt: `${faker.date.recent()}`, - body: faker.lorem.paragraph(), - progress: { - doneCount: faker.number.int(10), - inProgressCount: faker.number.int(10), - todoCount: faker.number.int(10), - enabled: true, - }, - }, - }, - }, - }) -} diff --git a/tests/mocks/api/github/graphql/projects.user.legacy.mjs b/tests/mocks/api/github/graphql/projects.user.legacy.mjs deleted file mode 100644 index add6638b6c6..00000000000 --- a/tests/mocks/api/github/graphql/projects.user.legacy.mjs +++ /dev/null @@ -1,24 +0,0 @@ -/**Mocked data */ -export default function({faker, query, login = faker.internet.userName()}) { - console.debug("metrics/compute/mocks > mocking graphql api result > projects/user.legacy") - return ({ - user: { - projects: { - totalCount: 1, - nodes: [ - { - name: "User-owned project", - updatedAt: `${faker.date.recent()}`, - body: faker.lorem.paragraph(), - progress: { - doneCount: faker.number.int(10), - inProgressCount: faker.number.int(10), - todoCount: faker.number.int(10), - enabled: true, - }, - }, - ], - }, - }, - }) -}